Anasayfa / Database / Postgresql / postgresql caesarCipher

postgresql caesarCipher

CREATE EXTENSION plpython3u;

CREATE OR REPLACE FUNCTION caesarCipher(realtext text, step int)
RETURNS TEXT
AS $$
    outText = []
    cryptText = []
    uppercase = ['A', 'B', 'C', 'Ç', 'D', 'E', 'F', 'G', 'Ğ',  'H', 'I', 'İ', 'J', 'K',  'L', 'M', 'N', 'O', 'Ö', 'P', 'Q', 'R', 'S', 'Ş', 'T', 'U', 'Ü', 'V', 'W', 'X', 'Y', 'Z']
    lowercase = ['a', 'b', 'c', 'ç', 'd', 'e', 'f', 'g', 'ğ',  'h', 'ı', 'i', 'j', 'k',  'l', 'm', 'n', 'o', 'ö', 'p', 'q', 'r', 's', 'ş', 't', 'u', 'ü', 'v', 'w', 'x', 'y', 'z']
    for eachLetter in realtext:
        if eachLetter in uppercase:
            index = uppercase.index(eachLetter)
            crypting = (index + step) % 32
            cryptText.append(crypting)
            newLetter = uppercase[crypting]
            outText.append(newLetter)
        elif eachLetter in lowercase:
            index = lowercase.index(eachLetter)
            crypting = (index + step) % 32
            cryptText.append(crypting)
            newLetter = lowercase[crypting]
            outText.append(newLetter)
        elif eachLetter == ' ':
            outText.append(' ')
        elif eachLetter == '.':
            outText.append('.')
    listToStr = ''.join([str(elem) for elem in outText])
    return listToStr
$$LANGUAGE 'plpython3u';

select caesarCipher('MOBİLYA VE',3)

 

Hakkında ibrahim

İlgili Makaleler

Postgresql gümrük beyanname tescil no regex domain

create domain dmn_tescilno varchar(16) check ( value ~ '^[0-9]{8}((IM)|(EX)|(AN)|(TR)|(DG)|(T0)|(C0)|(B0)|(G0)|(M0)|(R0)|(RL))[0-9]{6}$'); select '22222222AN111111'::dmn_tescilno;  

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir