Skip to content

Instantly share code, notes, and snippets.

@TheNilesh
TheNilesh / Python Blowfish ECB
Created September 5, 2017 10:54
Java compatible code in python
def encrypt(plaintext, key):
cipher = Blowfish.new(key, Blowfish.MODE_ECB)
packedString = pkcs5pad(plaintext)
return (base64.b64encode(cipher.encrypt(packedString))).decode("utf-8")
def decrypt(ciphertext, key):
cipher = Blowfish.new(key, Blowfish.MODE_ECB)
paddedstring = cipher.decrypt(base64.b64decode(ciphertext))
return pkcs5unpad(paddedstring).decode("utf-8")
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int count = scanner.nextInt();
for (int i = 0; i < count; i++) {
int N = scanner.nextInt(); /*Number of 0's*/