Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from blowfish import blowfish
- def enkripsi(key, word):
- T = blowfish(word.encode())
- x = T.encrypt(word.encode())
- return x
- def dekripsi(key, word):
- T = blowfish(str.encode(key))
- y = T.decrypt(word).decode()
- return y
- def readtext(path):
- file = open(path, 'r')
- text = file.read()
- return text
- def readbin(path):
- file = open(path, 'rb')
- text = file.read()
- return text
- def main():
- while (1):
- choice = int(input("\n 1.Encryption \n 2.Decryption: \n 3.EXIT \n Choice : "))
- if choice == 1:
- source = int(input("\n 1.From file \n 2.From text input \n Choice : "))
- if source == 1:
- path = input("Input file name (must contain 16 char): ")
- word = readtext(path)
- key = input("Input key : ")
- encrpyted = enkripsi(key, word)
- print("Encrypted : "+str(encrpyted))
- else:
- word = input("Input text (must contain 16 char): ")
- key = input("Input key : ")
- encrpyted = enkripsi(key, word)
- print("Encrypted : "+str(encrpyted))
- elif choice == 2:
- word = input("Input encrypted text: ")
- print(word)
- key = input("Input key : ")
- decrypted = dekripsi(key, word)
- print("Decrypted : "+decrypted)
- elif choice == 3:
- exit()
- else:
- print("Choose correct choice ")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement