100+ results for 'crypto.cip blowfish'

Not the results you expected?

DESCoder.java (https://bitbucket.org/beginnerjyh/es.git) Java · 132 lines

2

3 import javax.crypto.Cipher;

4 import javax.crypto.SecretKey;

12 * <pre>

13 * 支持 DES、DESede(TripleDES,就是3DES)、AES、Blowfish、RC2、RC4(ARCFOUR)

14 * DES key size must be equal to 56

16 * AES key size must be equal to 128, 192 or 256,but 192 and 256 bits may not be available

17 * Blowfish key size must be multiple of 8, and can only range from 32 to 448 (inclusive)

18 * RC2 key size must be between 40 and 1024 bits

34 * AES key size must be equal to 128, 192 or 256,but 192 and 256 bits may not be available

35 * Blowfish key size must be multiple of 8, and can only range from 32 to 448 (inclusive)

36 * RC2 key size must be between 40 and 1024 bits

StringEncrypter.java (https://gitlab.com/essere.lab.public/qualitas.class-corpus) Java · 312 lines

7 // CIPHER / GENERATORS

8 import javax.crypto.Cipher;

9 import javax.crypto.SecretKey;

224 SecretKey desKey = KeyGenerator.getInstance( "DES" ).generateKey();

225 SecretKey blowfishKey = KeyGenerator.getInstance( "Blowfish" ).generateKey();

226 SecretKey desedeKey = KeyGenerator.getInstance( "DESede" ).generateKey();

229 StringEncrypter desEncrypter = new StringEncrypter( desKey, desKey.getAlgorithm() );

230 StringEncrypter blowfishEncrypter = new StringEncrypter( blowfishKey, blowfishKey.getAlgorithm() );

231 StringEncrypter desedeEncrypter = new StringEncrypter( desedeKey, desedeKey.getAlgorithm() );

234 String desEncrypted = desEncrypter.encrypt( secretString );

235 String blowfishEncrypted = blowfishEncrypter.encrypt( secretString );

236 String desedeEncrypted = desedeEncrypter.encrypt( secretString );

239 String desDecrypted = desEncrypter.decrypt( desEncrypted );

240 String blowfishDecrypted = blowfishEncrypter.decrypt( blowfishEncrypted );

241 String desedeDecrypted = desedeEncrypter.decrypt( desedeEncrypted );

Blowfish.py (https://gitlab.com/grayhamster/pycrypto) Python · 132 lines

2 #

3 # Cipher/Blowfish.py : Blowfish

4 #

33

34 >>> from Crypto.Cipher import Blowfish

35 >>> from Crypto import Random

40 >>> iv = Random.new().read(bs)

41 >>> cipher = Blowfish.new(key, Blowfish.MODE_CBC, iv)

42 >>> plaintext = b'docendo discimus '

47

48 .. _Blowfish: http://www.schneier.com/blowfish.html

49

55 from Crypto.Cipher import blockalgo

56 from Crypto.Cipher import _Blowfish

57

Blowfish.java (https://gitlab.com/brian0218/rk3188_rk3066_r-box_android4.4.2_sdk) Java · 77 lines

2

3 import org.bouncycastle.crypto.CipherKeyGenerator;

4 import org.bouncycastle.crypto.engines.BlowfishEngine;

11

12 public final class Blowfish

13 {

14 private Blowfish()

15 {

22 {

23 super(new BlowfishEngine());

24 }

31 {

32 super(new CBCBlockCipher(new BlowfishEngine()), 64);

33 }

StringOBF.java (https://gitlab.com/N00bVip/Noxious) Java · 88 lines

7

8 import javax.crypto.Cipher;

9 import javax.crypto.spec.SecretKeySpec;

16 SecretKeySpec sksSpec =

17 new SecretKeySpec(key.getBytes(), "Blowfish");

18

19 Cipher cipher = Cipher.getInstance("Blowfish");

20 cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, sksSpec);

51 SecretKeySpec sksSpec =

52 new SecretKeySpec(key.getBytes(), "Blowfish");

53

54 Cipher cipher = Cipher.getInstance("Blowfish");

55 cipher.init(Cipher.DECRYPT_MODE, sksSpec);

encrypted.py (https://bitbucket.org/vitormazzi/skink.git) Python · 106 lines

6 encrypted and safely encoded for storage in a unicode column using the powerful

7 and secure Blowfish Cipher using a specified "secret" which can be passed into

8 the plugin at class declaration time.

28

29 from Crypto.Cipher import Blowfish

30 from elixir.statements import Statement

41 def encrypt_value(value, secret):

42 return Blowfish.new(secret, Blowfish.MODE_CFB) \

43 .encrypt(value).encode('string_escape')

45 def decrypt_value(value, secret):

46 return Blowfish.new(secret, Blowfish.MODE_CFB) \

47 .decrypt(value.decode('string_escape'))

CipherWithWrappingSpi.java (https://github.com/ikeji/openjdk7-jdk.git) Java · 261 lines

38

39 import javax.crypto.Cipher;

40 import javax.crypto.CipherSpi;

46 /**

47 * This class entends the javax.crypto.CipherSpi class with a concrete

48 * implementation of the methods for wrapping and unwrapping

53 *

54 * @see javax.crypto.CipherSpi

55 * @see BlowfishCipher

BlowfishCBC.java (https://github.com/xv1t/SquidModel.GUI.git) Java · 70 lines

34

35 public class BlowfishCBC implements Cipher{

36 private static final int ivsize=8;

37 private static final int bsize=16;

38 private javax.crypto.Cipher cipher;

39 public int getIVSize(){return ivsize;}

56 SecretKeySpec skeySpec = new SecretKeySpec(key, "Blowfish");

57 cipher=javax.crypto.Cipher.getInstance("Blowfish/CBC/"+pad);

58 cipher.init((mode==ENCRYPT_MODE?

59 javax.crypto.Cipher.ENCRYPT_MODE:

60 javax.crypto.Cipher.DECRYPT_MODE),

gnu.javax.crypto.cipher.java (https://github.com/facebook/pfff.git) Java · 400 lines

1 package gnu.javax.crypto.cipher;

2 class WeakKeyException {

350 }

351 class Blowfish {

352 class Block {

TestLadderEncoding.java (https://github.com/ickik/TestLadder.git) Java · 131 lines

8 import javax.crypto.BadPaddingException;

9 import javax.crypto.Cipher;

10 import javax.crypto.IllegalBlockSizeException;

24

25 private static final String ALGORITHM = "Blowfish";

26 private static final String TRANSFORMATION = "Blowfish/CBC/PKCS5Padding";

34 * stored in local.

35 * <br>The algorithm chooses is blowfish.

36 * @param login the login of the user used as key.

37 * @param password the password associates to the login.

38 * @return the password encrypted with blowfish algorithm.

39 * @throws LadderException this exception is thrown when an error occurs

69 * stored in local.

70 * <br>The algorithm chooses is blowfish.

71 * @param login the login of the user used as key.

BlockCipherFactory.java (https://gitlab.com/imxieke/remote-desktop-clients) Java · 115 lines

1

2 package com.trilead.ssh2.crypto.cipher;

3

35

36 ciphers.addElement(new CipherEntry("aes256-ctr", 16, 32, "com.trilead.ssh2.crypto.cipher.AES"));

37 ciphers.addElement(new CipherEntry("aes192-ctr", 16, 24, "com.trilead.ssh2.crypto.cipher.AES"));

38 ciphers.addElement(new CipherEntry("aes128-ctr", 16, 16, "com.trilead.ssh2.crypto.cipher.AES"));

39 ciphers.addElement(new CipherEntry("blowfish-ctr", 8, 16, "com.trilead.ssh2.crypto.cipher.BlowFish"));

40

41 ciphers.addElement(new CipherEntry("aes256-cbc", 16, 32, "com.trilead.ssh2.crypto.cipher.AES"));

42 ciphers.addElement(new CipherEntry("aes192-cbc", 16, 24, "com.trilead.ssh2.crypto.cipher.AES"));

43 ciphers.addElement(new CipherEntry("aes128-cbc", 16, 16, "com.trilead.ssh2.crypto.cipher.AES"));

44 ciphers.addElement(new CipherEntry("blowfish-cbc", 8, 16, "com.trilead.ssh2.crypto.cipher.BlowFish"));

45

Blowfish.java (https://gitlab.com/rizon/acid.git) Java · 294 lines

3 /**

4 * Blowfish.java version 1.00.00

5 *

32 import java.security.InvalidKeyException;

33 import javax.crypto.Cipher;

34 import javax.crypto.spec.SecretKeySpec;

37

38 public class Blowfish

39 {

40 private static final Logger log = LoggerFactory.getLogger(Blowfish.class);

41

42 /*

43 * Constructor of Blowfish class Key param

44 */

cryptocipher.py (https://github.com/dahool/vertaal.git) Python · 69 lines

20 import base64

21 from Crypto.Cipher import Blowfish

22 from django.conf import settings

27 pwd = getattr(settings, 'SECRET_KEY')

28 self.__cipher = Blowfish.new(pwd)

29 def encrypt(self, text):

39 return cleartext

40 # Blowfish cipher needs 8 byte blocks to work with

41 def __pad_file(self, text):

crypto.py (https://code.google.com/p/wallproxy-plugins/) Python · 130 lines

33

34 _BlockSize = {'AES':16, 'ARC2':8, 'ARC4':1, 'Blowfish':8, 'CAST':8,

35 'DES':8, 'DES3':8, 'IDEA':8, 'RC5':8, 'XOR':1}

63 if self.cipher=='RC5' and self.keysize in (1, 57): self.keysize=32

64 #try to import Crypto.Cipher.xxxx

65 try:

66 cipherlib = __import__('Crypto.Cipher.'+self.cipher, fromlist='x')

67 self._newobj = cipherlib.new

models.py (https://github.com/goodguy/satchmo.git) Python · 127 lines

5

6 from Crypto.Cipher import Blowfish

7 from datetime import datetime

111 """Decrypt code encrypted by _encrypt_code"""

112 # In some blowfish implementations, > 56 char keys can cause problems

113 secret_key = settings.SECRET_KEY[:56]

114 encryption_object = Blowfish.new(secret_key)

115 # strip padding from decrypted credit card number

119 """Quick encrypter for CC codes or code fragments"""

120 # In some blowfish implementations, > 56 char keys can cause problems

121 secret_key = settings.SECRET_KEY[:56]

122 encryption_object = Blowfish.new(secret_key)

123 # block cipher length must be a multiple of 8

Turkish.java (https://github.com/shchiu/openjdk.git) Java · 49 lines

32

33 import javax.crypto.Cipher;

34

42 System.out.println(Cipher.getInstance("rsa/ecb/pkcs1padding"));

43 System.out.println(Cipher.getInstance("Blowfish"));

44 System.out.println(Cipher.getInstance("blowfish"));

45 System.out.println(Cipher.getInstance("BLOWFISH"));

46

__init__.py (https://github.com/volpino/Yeps-EURAC.git) Python · 58 lines

5

6 from Crypto.Cipher import Blowfish

7 from Crypto.Util.randpool import RandomPool

35 self.id_secret = config['id_secret']

36 self.id_cipher = Blowfish.new( self.id_secret )

37 def encode_id( self, obj_id ):

util.py (https://bitbucket.org/nicste/ballaxy.git) Python · 32 lines

2 pkg_resources.require( "pycrypto" )

3 from Crypto.Cipher import Blowfish

4

14 user_hash = ( "!" * ( 8 - len( user_hash ) % 8 ) ) + user_hash

15 cipher = Blowfish.new( str( dataset.create_time ) )

16 user_hash = cipher.encrypt( user_hash ).encode( 'hex' )

27 else:

28 cipher = Blowfish.new( str( dataset.create_time ) )

29 user_id = cipher.decrypt( user_hash.decode( 'hex' ) ).lstrip( "!" )

Cipher.hs (git://github.com/vincenthz/hs-cryptocipher.git) Haskell · 57 lines

1 -- |

2 -- Module : Crypto.Cipher

3 -- License : BSD-style

12 --

13 -- > import Crypto.Cipher

14 -- > import Data.ByteString (ByteString)

23 --

24 module Crypto.Cipher

25 (

45 , AES128, AES192, AES256

46 , Blowfish, Blowfish64, Blowfish128, Blowfish256, Blowfish448

47 , DES

53 import Crypto.Cipher.AES (AES128, AES192, AES256)

54 import Crypto.Cipher.Blowfish

55 import Crypto.Cipher.DES

CipherFactory.java (https://github.com/clibrepo/04f6ea02286af71632b72d73554979a61da424cf681886674b21ecd595715c12.git) Java · 150 lines

1 package gnu.crypto.cipher;

2

91 result = new Anubis();

92 } else if (name.equalsIgnoreCase(BLOWFISH_CIPHER)) {

93 result = new Blowfish();

133 hs.add(ANUBIS_CIPHER);

134 hs.add(BLOWFISH_CIPHER);

135 hs.add(DES_CIPHER);

BlowfishSerializer.java (https://gitlab.com/kidaa/kryo.git) Java · 82 lines

23

24 import javax.crypto.Cipher;

25 import javax.crypto.CipherInputStream;

26 import javax.crypto.CipherOutputStream;

27 import javax.crypto.spec.SecretKeySpec;

34

35 /** Encrypts data using the blowfish cipher.

36 * @author Nathan Sweet <misc@n4te.com> */

37 public class BlowfishSerializer extends Serializer {

38 private final Serializer serializer;

40

41 public BlowfishSerializer (Serializer serializer, byte[] key) {

42 this.serializer = serializer;

KeyGen.java (http://aionxemu.googlecode.com/svn/trunk/) Java · 97 lines

22

23 import javax.crypto.Cipher;

24 import javax.crypto.KeyGenerator;

30 /**

31 * Key generator. It generates keys or keyPairs for Blowfish and RSA

32 *

41 /**

42 * Key generator for blowfish

43 */

44 private static KeyGenerator blowfishKeyGen;

45

58

59 blowfishKeyGen = KeyGenerator.getInstance("Blowfish");

60

__init__.py (https://bitbucket.org/chapmanb/galaxy-central/) Python · 76 lines ✨ Summary

This Python code provides a SecurityHelper class that handles encryption and decryption of IDs using Blowfish cipher. It generates random bytes for high entropy values, encodes IDs as hexadecimal strings, and decodes them back to integers. The class also includes functions to encode GUIDs (Globally Unique Identifiers) and generate new GUIDs.

5

6 from Crypto.Cipher import Blowfish

7 from Crypto.Util.randpool import RandomPool

37 self.id_secret = config['id_secret']

38 self.id_cipher = Blowfish.new( self.id_secret )

39

JCEKeyGenerator.java (https://github.com/MIPS/external-bouncycastle.git) Java · 538 lines

2

3 import org.bouncycastle.crypto.CipherKeyGenerator;

4 import org.bouncycastle.crypto.KeyGenerationParameters;

174 /**

175 * Blowfish

176 */

177 public static class Blowfish

178 extends JCEKeyGenerator

179 {

180 public Blowfish()

181 {

182 super("Blowfish", 128, new CipherKeyGenerator());

183 }

__init__.py (https://gitlab.com/grayhamster/pycrypto) Python · 83 lines

41 ======================== ======= ========================

42 `Crypto.Cipher.AES` Block Advanced Encryption Standard

43 `Crypto.Cipher.ARC2` Block Alleged RC2

44 `Crypto.Cipher.ARC4` Stream Alleged RC4

45 `Crypto.Cipher.Blowfish` Block Blowfish

46 `Crypto.Cipher.CAST` Block CAST

47 `Crypto.Cipher.DES` Block The Data Encryption Standard.

48 Very commonly used in the past,

49 but today its 56-bit keys are too small.

50 `Crypto.Cipher.DES3` Block Triple DES.

51 `Crypto.Cipher.XOR` Stream The simple XOR cipher.

66 ========================== =======================

67 `Crypto.Cipher.PKCS1_v1_5` PKCS#1 v1.5 encryption, based on RSA key pairs

68 `Crypto.Cipher.PKCS1_OAEP` PKCS#1 OAEP encryption, based on RSA key pairs

Tests.hs (git://github.com/vincenthz/hs-cryptocipher.git) Haskell · 51 lines

4 import Test.Framework (defaultMain, testGroup)

5 import Crypto.Cipher.Blowfish

6 import Crypto.Cipher.Types

7 import Crypto.Cipher.Tests

8 import Data.ByteString.Char8 () -- orphan IsString for older bytestring versions

49 main = defaultMain

50 [ testBlockCipher kats (undefined :: Blowfish64)

51 ]

SecretKeyEncryptionStrategy.java (https://gitlab.com/thugside/mule) Java · 124 lines

16

17 import javax.crypto.Cipher;

18 import javax.crypto.KeyGenerator;

25 * A keyFactory is an implementation of {@link SecretKeyFactory} and must return a

26 * byte array. The default algorthm used by this strategy is Blowfish, but users can

27 * specify any valid algorithm supported by JCE.

37

38 public static final String DEFAULT_ALGORITHM = "Blowfish";

39

GnuCrypto.java (https://github.com/penberg/classpath.git) Java · 598 lines

41 import gnu.java.security.Registry;

42 import gnu.javax.crypto.cipher.CipherFactory;

43 import gnu.javax.crypto.mac.MacFactory;

74 put("Cipher.ARCFOUR ImplementedIn", "Software");

75 put("Cipher.BLOWFISH",

76 gnu.javax.crypto.jce.cipher.BlowfishSpi.class.getName());

77 put("Cipher.BLOWFISH ImplementedIn", "Software");

78 put("Cipher.DES", gnu.javax.crypto.jce.cipher.DESSpi.class.getName());

112 gnu.javax.crypto.jce.cipher.PBES2.HMacHaval.Anubis.class.getName());

113 put("Cipher.PBEWithHMacHavalAndBlowfish",

114 gnu.javax.crypto.jce.cipher.PBES2.HMacHaval.Blowfish.class.getName());

133 gnu.javax.crypto.jce.cipher.PBES2.HMacMD2.Anubis.class.getName());

134 put("Cipher.PBEWithHMacMD2AndBlowfish",

135 gnu.javax.crypto.jce.cipher.PBES2.HMacMD2.Blowfish.class.getName());

PEMUtilities.java (https://gitlab.com/essere.lab.public/qualitas.class-corpus) Java · 185 lines

6

7 import javax.crypto.Cipher;

8 import javax.crypto.SecretKey;

70 {

71 alg = "Blowfish";

72 sKey = getKey(password, alg, 16, iv);

__init__.py (https://github.com/dahool/vertaal.git) Python · 120 lines

35 Cipher.__init__(self, key)

36 self.__cipher = Blowfish(key)

37

60

61 # Blowfish cipher needs 8 byte blocks to work with

62 def __pad_text(self, text):

81 Cipher.__init__(self, key)

82 self.__cipher = Blowfish.new(key)

83

115 try:

116 from Crypto.Cipher import Blowfish

117 cipher = CryptoCipher

118 except:

119 from blowfishcipher.blowfish import Blowfish

120 cipher = LocalCipher

__init__.py (https://github.com/ambv/kitpy.git) Python · 59 lines

36 from Crypto.Cipher import AES as _AES

37 from Crypto.Cipher import Blowfish as _Blowfish

38 from Crypto.Cipher import CAST as _CAST

39 from Crypto.Cipher import DES as _DES

40 from Crypto.Cipher import DES3 as _DES3

47 part.__name__ = name.lower()

48 part.__module__ = b'lck.crypto.cipher'

49 part.__doc__ = ("{}([key, path, create]) -> Cipher instance\n\nFactory "

55 aes = _setup_cipher(_AES)

56 blowfish = _setup_cipher(_Blowfish)

57 cast = _setup_cipher(_CAST)

Blowfish.java (https://gitlab.com/essere.lab.public/qualitas.class-corpus) Java · 107 lines

28 import javax.crypto.BadPaddingException;

29 import javax.crypto.Cipher;

30 import javax.crypto.IllegalBlockSizeException;

35

36 public class Blowfish {

37 private static final Logger LOG = Logger

38 .getLogger("org.columba.util.blowfish");

39

42

43 private static final Key KEY = new SecretKeySpec(BYTES, "Blowfish");

44

47 // Create the cipher

48 Cipher blowCipher = Cipher.getInstance("Blowfish");

49

models.py (https://github.com/Ryati/satchmo.git) Python · 124 lines

5

6 from Crypto.Cipher import Blowfish

7 from datetime import datetime

111 secret_key = settings.SECRET_KEY

112 encryption_object = Blowfish.new(secret_key)

113 # strip padding from decrypted credit card number

118 secret_key = settings.SECRET_KEY

119 encryption_object = Blowfish.new(secret_key)

120 # block cipher length must be a multiple of 8

DiffieHellman.scala (https://github.com/xrayn/tpm-scala.git) Scala · 160 lines

7 import scala.util.Random

8 import javax.crypto.Cipher

9 import javax.crypto.KeyGenerator

29

30 def encryptBlowfish(aesKey: String, peerPubKey: Option[String]): Option[String] = {

31

37 val sharedKey = getSharedKey().toString().getBytes()

38 val myKeySpec = new SecretKeySpec(sharedKey, "Blowfish");

39 val cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");

50

51 def decryptBlowfish(aesKey: String, peerPubKey: Option[String]): Option[String] = {

52

60 val sharedKey = getSharedKey().toString().getBytes()

61 val myKeySpec = new SecretKeySpec(sharedKey, "Blowfish");

62 val cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");

BlockCipherFactory.java (https://github.com/8nevil8/ganymed-ssh-2.git) Java · 130 lines

4 */

5 package ch.ethz.ssh2.crypto.cipher;

6

39 /* Higher Priority First */

40 ciphers.add(new CipherEntry("aes128-ctr", 16, 16, "ch.ethz.ssh2.crypto.cipher.AES"));

41 ciphers.add(new CipherEntry("aes192-ctr", 16, 24, "ch.ethz.ssh2.crypto.cipher.AES"));

42 ciphers.add(new CipherEntry("aes256-ctr", 16, 32, "ch.ethz.ssh2.crypto.cipher.AES"));

43 ciphers.add(new CipherEntry("blowfish-ctr", 8, 16, "ch.ethz.ssh2.crypto.cipher.BlowFish"));

44

45 ciphers.add(new CipherEntry("aes128-cbc", 16, 16, "ch.ethz.ssh2.crypto.cipher.AES"));

46 ciphers.add(new CipherEntry("aes192-cbc", 16, 24, "ch.ethz.ssh2.crypto.cipher.AES"));

47 ciphers.add(new CipherEntry("aes256-cbc", 16, 32, "ch.ethz.ssh2.crypto.cipher.AES"));

48 ciphers.add(new CipherEntry("blowfish-cbc", 8, 16, "ch.ethz.ssh2.crypto.cipher.BlowFish"));

49

config.py (https://github.com/ahri/financials.git) Python · 47 lines

5

6 from Crypto.Cipher import Blowfish as crypto

7 import simplejson as json

__init__.py (https://bitbucket.org/galaxy/galaxy-central/) Python · 131 lines

7

8 from Crypto.Cipher import Blowfish

9 from Crypto.Util.randpool import RandomPool

40 self.id_secret = config['id_secret']

41 self.id_cipher = Blowfish.new( self.id_secret )

42

129 def __missing__( self, key ):

130 return Blowfish.new( self.secret_base + "__" + key )

131

models.py (https://github.com/davemerwin/satchmo.git) Python · 82 lines

5

6 from Crypto.Cipher import Blowfish

7 from django.conf import settings

59 secret_key = settings.SECRET_KEY

60 encryption_object = Blowfish.new(secret_key)

61 # block cipher length must be a multiple of 8

69 secret_key = settings.SECRET_KEY

70 encryption_object = Blowfish.new(secret_key)

71 # strip padding from decrypted credit card number

Cryption.java (https://github.com/aharisu/SyncBookmark.git) Java · 68 lines

6 import javax.crypto.BadPaddingException;

7 import javax.crypto.Cipher;

8 import javax.crypto.IllegalBlockSizeException;

17 public class Cryption {

18 private static final String TRANSFORMATION = "Blowfish";

19

27 Cipher cipher = Cipher.getInstance(TRANSFORMATION);

28 cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, spec);

29 return cipher.doFinal(text.getBytes());

50 Cipher cipher = Cipher.getInstance(TRANSFORMATION);

51 cipher.init(javax.crypto.Cipher.DECRYPT_MODE, spec);

52 return new String(cipher.doFinal(encrypted));

SilverCryptFactorySymetric.java (https://github.com/NicolasEYSSERIC/Silverpeas-Core.git) Java · 138 lines

30 import java.security.NoSuchAlgorithmException;

31 import javax.crypto.Cipher;

32 import javax.crypto.NoSuchPaddingException;

35

36 public static final String ALGORITHM = "Blowfish";

37 /**

misc.py (https://github.com/tsaylor/BARcamp-Chicago-Website.git) Python · 43 lines

5

6 from Crypto.Cipher import Blowfish

7 from base64 import *

12 def cryptString( secret, plain ):

13 obj = Blowfish.new( secret, Blowfish.MODE_ECB )

14 #randstring = unicode(open("/dev/urandom").read(12), 'ascii', 'ignore')

30 def decryptString( secret, cipher ):

31 obj = Blowfish.new( secret, Blowfish.MODE_ECB )

32 try:

SecretUtils.java (https://gitlab.com/JingYing/paipaiapp) Java · 152 lines

5

6 import javax.crypto.Cipher;

7 import javax.crypto.SecretKey;

CodecAndCryptoTest.java (https://gitlab.com/0072016/0072016-show) Java · 203 lines

12

13 import javax.crypto.Cipher;

14 import java.security.*;

161 public void testBlowfishCipherService() {

162 BlowfishCipherService blowfishCipherService = new BlowfishCipherService();

163 blowfishCipherService.setKeySize(128);

165 //生成key

166 Key key = blowfishCipherService.generateNewKey();

167

170 //加密

171 String encrptText = blowfishCipherService.encrypt(text.getBytes(), key.getEncoded()).toHex();

172 //解密

173 String text2 = new String(blowfishCipherService.decrypt(Hex.decode(encrptText), key.getEncoded()).getBytes());

174

BlowfishJC.java (https://github.com/aldago/DQLScriptExecutor.git) Java · 180 lines

7

8 import javax.crypto.Cipher;

9 import javax.crypto.spec.SecretKeySpec;

12 *

13 * Blowfish encrypt/decrypt algorithm wrappers around the Java Crypto API

14 * implementation

18 */

19 public class BlowfishJC

20 {

21

22 private BlowfishJC()

23 {

38 * Algo Specs:

39 * Blowfish/ECB/PKCS5Padding

40 *

CipherFactory.java (https://github.com/penberg/classpath.git) Java · 129 lines

38

39 package gnu.javax.crypto.cipher;

40

75 result = new Anubis();

76 else if (name.equalsIgnoreCase(BLOWFISH_CIPHER))

77 result = new Blowfish();

116 hs.add(ANUBIS_CIPHER);

117 hs.add(BLOWFISH_CIPHER);

118 hs.add(DES_CIPHER);

ERXAbstractBlowfishCrypter.java (https://github.com/dbaillon/wonder.git) Java · 226 lines

14 /**

15 * ERXAbstractBlowfishCrypter is a blowfish implementation of the crypter

16 * interface that allows subclasses to override the source of the blowfish key.

17 * The blowfish cipher is a two-way cipher meaning the original string that was

18 * encrypted can be retrieved. The way that this version of the blowfish cipher

19 * is encrypted it is safe to use as a form value.

75 try {

76 Cipher cipher = Cipher.getInstance("Blowfish/ECB/NoPadding");

77 cipher.init(mode, secretBlowfishKey());

101 /**

102 * Method used to return the shared instance of the blowfish decryption

103 * cipher.

179 * Blowfish encodes a given string using the secret key specified in the

180 * System property: <b>ERBlowfishCipherKey</b>. The blowfish cipher is a

181 * two way cipher meaning that given the secret key you can de-cipher what

SIDCrypto.py (https://gitlab.com/bcolin/sid) Python · 193 lines

1 from Crypto.Cipher import AES,Blowfish,CAST,DES3

2 from Crypto.Hash import MD5,SHA256,SHA512

30

31 algos = {"AES":AES, "Blowfish":Blowfish, "CAST":CAST, "DES3":DES3, "SHA256":SHA256, "SHA512":SHA512, \

32 "MD5":MD5, "None":Null}

__init__.py (https://github.com/dbcls/dbcls-galaxy.git) Python · 60 lines

5

6 from Crypto.Cipher import Blowfish

7 from Crypto.Util.randpool import RandomPool

37 self.id_secret = config['id_secret']

38 self.id_cipher = Blowfish.new( self.id_secret )

39 def encode_id( self, id ):

Eryptogram.java (http://liweistudy.googlecode.com/svn/trunk/) Java · 145 lines

12 */

13 import javax.crypto.Cipher;

14 import javax.crypto.KeyGenerator;

24 private static String Algorithm = "DES";

25 // ?? ????,?? DES,DESede,Blowfish

26 static boolean debug = false;

StringEncrypter.java (https://github.com/bowler-framework/recursivity-commons.git) Java · 240 lines

4 // CIPHER / GENERATORS

5 import javax.crypto.Cipher;

6 import javax.crypto.SecretKey;

195 SecretKey desKey = KeyGenerator.getInstance("DES").generateKey();

196 SecretKey blowfishKey = KeyGenerator.getInstance("Blowfish").generateKey();

197 SecretKey desedeKey = KeyGenerator.getInstance("DESede").generateKey();

200 StringEncrypter desEncrypter = new StringEncrypter(desKey, desKey.getAlgorithm());

201 StringEncrypter blowfishEncrypter = new StringEncrypter(blowfishKey, blowfishKey.getAlgorithm());

202 StringEncrypter desedeEncrypter = new StringEncrypter(desedeKey, desedeKey.getAlgorithm());

205 String desEncrypted = desEncrypter.encrypt(secretString);

206 String blowfishEncrypted = blowfishEncrypter.encrypt(secretString);

207 String desedeEncrypted = desedeEncrypter.encrypt(secretString);

210 String desDecrypted = desEncrypter.decrypt(desEncrypted);

211 String blowfishDecrypted = blowfishEncrypter.decrypt(blowfishEncrypted);

212 String desedeDecrypted = desedeEncrypter.decrypt(desedeEncrypted);

AbstractBlowfishCipher.java (https://gitlab.com/rwf/blowfish-hasher) Java · 51 lines

1 package org.filho.util.blowfish.cipher;

2

5

6 import javax.crypto.Cipher;

7 import javax.crypto.NoSuchPaddingException;

9

10 import org.filho.util.blowfish.hasher.Mode;

11

12 /**

13 * Contains all the methods to manipulate the blowfish hashes.

14 * @author Roberto Filho

16 */

17 public abstract class AbstractBlowfishCipher {

18

19 public Cipher getCipher(Mode mode, SecretKeySpec keySpec) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException {

20 // Use blowfish with ECB and PKCS5 padding

21 Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");

models.py (https://github.com/roadhead/satchmo.git) Python · 106 lines

5

6 from Crypto.Cipher import Blowfish

7 from datetime import datetime

66 secret_key = settings.SECRET_KEY

67 encryption_object = Blowfish.new(secret_key)

68 # block cipher length must be a multiple of 8

93 secret_key = settings.SECRET_KEY

94 encryption_object = Blowfish.new(secret_key)

95 # strip padding from decrypted credit card number

BlowfishCbc.java (http://ece01sd.googlecode.com/svn/trunk/) Java · 129 lines

36

37 import javax.crypto.Cipher;

38 import javax.crypto.NoSuchPaddingException;

48 */

49 public class BlowfishCbc extends SshCipher {

50 private static Log log = LogFactory.getLog(BlowfishCbc.class);

52 /** */

53 protected static String algorithmName = "blowfish-cbc";

54 Cipher cipher;

56 /**

57 * Creates a new BlowfishCbc object.

58 */

59 public BlowfishCbc() {

60 }

BlowfishKey.java (https://github.com/muness/blowfish_encryption_example.git) Java · 74 lines

1 import javax.crypto.Cipher;

2 import java.security.Key;

17

18 public class BlowfishKey {

19

34 public static byte[] encrypt(String plainText) throws Exception {

35 Cipher cipher = Cipher.getInstance("Blowfish");

36 cipher.init(Cipher.ENCRYPT_MODE, getKeySpec());

48 public static String decrypt(byte[] cipherText) throws Exception {

49 Cipher cipher = Cipher.getInstance("Blowfish");

50 cipher.init(Cipher.DECRYPT_MODE, getKeySpec());

58 byte[] raw = getKey();

59 return (new SecretKeySpec(raw, "Blowfish"));

60 }

encrypted.py (https://github.com/jespino/niwi-web.git) Python · 58 lines

9 try:

10 from Crypto.Cipher import Blowfish

11 except ImportError:

18 def __init__(self, *args, **kwargs):

19 self.cipher = Blowfish.new(settings.SECRET_KEY[:10])

20 super(BaseEncryptedField, self).__init__(*args, **kwargs)

fileconfigmanager.py (https://github.com/donaldharvey/snappy.git) Python · 135 lines

4 import os

5 from Crypto.Cipher import Blowfish #for password storage

6 from hashlib import sha1

52 cryptkey = sha1(key).hexdigest()

53 bf = Blowfish.new(cryptkey, Blowfish.MODE_ECB)

54 encrypted_pass = bf.encrypt(self._pad_pass(password))

59 cryptkey = sha1(key).hexdigest()

60 bf = Blowfish.new(cryptkey, Blowfish.MODE_ECB)

61 try:

models.py (https://github.com/CulturePlex/Sylva.git) Python · 161 lines

2 import binascii

3 from Crypto.Cipher import Blowfish

4

144 return u""

145 enc_obj = Blowfish.new(settings.SECRET_KEY)

146 hex_password = binascii.a2b_hex(self.encrypted_password)

152 else:

153 enc_obj = Blowfish.new(settings.SECRET_KEY)

154 repeat = 8 - (len(value) % 8)

BlockCipherResetTest.java (https://gitlab.com/edgardo001/bc-java) Java · 206 lines

3 import org.bouncycastle.crypto.BlockCipher;

4 import org.bouncycastle.crypto.CipherParameters;

5 import org.bouncycastle.crypto.DataLengthException;

9 import org.bouncycastle.crypto.engines.AESLightEngine;

10 import org.bouncycastle.crypto.engines.BlowfishEngine;

11 import org.bouncycastle.crypto.engines.CAST5Engine;

62 testReset("DESEngine", new DESEngine(), new DESEngine(), new KeyParameter(new byte[8]));

63 testReset("BlowfishEngine", new BlowfishEngine(), new BlowfishEngine(), new KeyParameter(new byte[8]));

64 testReset("CAST5Engine", new CAST5Engine(), new CAST5Engine(), new KeyParameter(new byte[8]));

common.py (https://bitbucket.org/chapmanb/galaxy-central/) Python · 167 lines

13 pkg_resources.require( "pycrypto" )

14 from Crypto.Cipher import Blowfish

15 from Crypto.Util.randpool import RandomPool

19 # Utility method to encode ID's

20 id_cipher = Blowfish.new( config_id_secret )

21 # Convert to string

__init__.py (https://github.com/wizzk42/pycrypto.git) Python · 82 lines

41 ====================== ====================

42 Crypto.Cipher.AES Advanced Encryption Standard

43 Crypto.Cipher.ARC2 Alleged RC2

44 Crypto.Cipher.ARC4 Alleged RC4

45 Crypto.Cipher.Blowfish Blowfish

46 Crypto.Cipher.CAST CAST

47 Crypto.Cipher.DES The Data Encryption Standard.

48 Very commonly used in the past,

49 but today its 56-bit keys are too small.

50 Crypto.Cipher.DES3 Triple DES.

51 Crypto.Cipher.XOR The simple XOR cipher.

66 ======================== =======================

67 Crypto.Cipher.PKCS1_v1.5 PKCS#1 v1.5 encryption, based on RSA key pairs

68 Crypto.Cipher.PKCS1_OAEP PKCS#1 OAEP encryption, based on RSA key pairs

KeyGen.java (https://github.com/osiris087/aionj.git) Java · 86 lines

6

7 import javax.crypto.Cipher;

8 import javax.crypto.KeyGenerator;

15 /**

16 * Key generator. It generates keys or keyPairs for Blowfish and RSA

17 *

28 /**

29 * Key generator for blowfish

30 */

31 private static KeyGenerator blowfishKeyGen;

32

46

47 blowfishKeyGen = KeyGenerator.getInstance("Blowfish");

48

Blowfish.java (https://gitlab.com/edgardo001/bc-java) Java · 88 lines

25 {

26 super(new BlowfishEngine());

27 }

61 {

62 return "Blowfish IV";

63 }

68 {

69 private static final String PREFIX = Blowfish.class.getName();

70

81 provider.addAlgorithm("KeyGenerator.BLOWFISH", PREFIX + "$KeyGen");

82 provider.addAlgorithm("Alg.Alias.KeyGenerator", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, "BLOWFISH");

83 provider.addAlgorithm("AlgorithmParameters.BLOWFISH", PREFIX + "$AlgParams");

84 provider.addAlgorithm("Alg.Alias.AlgorithmParameters", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, "BLOWFISH");

85

BlockCipherFactory.java (https://github.com/northern-bites/ganymed-ssh2.git) Java · 115 lines

1

2 package ch.ethz.ssh2.crypto.cipher;

3

35

36 ciphers.addElement(new CipherEntry("aes256-ctr", 16, 32, "ch.ethz.ssh2.crypto.cipher.AES"));

37 ciphers.addElement(new CipherEntry("aes192-ctr", 16, 24, "ch.ethz.ssh2.crypto.cipher.AES"));

38 ciphers.addElement(new CipherEntry("aes128-ctr", 16, 16, "ch.ethz.ssh2.crypto.cipher.AES"));

39 ciphers.addElement(new CipherEntry("blowfish-ctr", 8, 16, "ch.ethz.ssh2.crypto.cipher.BlowFish"));

40

41 ciphers.addElement(new CipherEntry("aes256-cbc", 16, 32, "ch.ethz.ssh2.crypto.cipher.AES"));

42 ciphers.addElement(new CipherEntry("aes192-cbc", 16, 24, "ch.ethz.ssh2.crypto.cipher.AES"));

43 ciphers.addElement(new CipherEntry("aes128-cbc", 16, 16, "ch.ethz.ssh2.crypto.cipher.AES"));

44 ciphers.addElement(new CipherEntry("blowfish-cbc", 8, 16, "ch.ethz.ssh2.crypto.cipher.BlowFish"));

45

BlowfishCBC.java (https://github.com/ePaul/jsch-documentation.git) Java · 73 lines

34

35 public class BlowfishCBC implements Cipher{

36 private static final int ivsize=8;

37 private static final int bsize=16;

38 private javax.crypto.Cipher cipher;

39 public int getIVSize(){return ivsize;}

56 SecretKeySpec skeySpec = new SecretKeySpec(key, "Blowfish");

57 cipher=javax.crypto.Cipher.getInstance("Blowfish/CBC/"+pad);

58 synchronized(javax.crypto.Cipher.class){

59 cipher.init((mode==ENCRYPT_MODE?

60 javax.crypto.Cipher.ENCRYPT_MODE:

61 javax.crypto.Cipher.DECRYPT_MODE),

BlowFishKey.java (https://github.com/ichiro101/l2adena-l2j-core.git) Java · 74 lines

20

21 import javax.crypto.Cipher;

22

33 */

34 public class BlowFishKey extends BaseRecievePacket

35 {

36 protected static final Logger _log = Logger.getLogger(BlowFishKey.class.getName());

37 /**

39 */

40 public BlowFishKey(byte[] decrypt, GameServerThread server)

41 {

61

62 server.SetBlowFish(new NewCrypt(key));

63 if (Config.DEBUG)

README.md (git://github.com/vincenthz/hs-cryptocipher.git) Markdown · 76 lines

10

11 import Crypto.Cipher.Types

12 import Crypto.Cipher

23

24 And another using CBC mode with Blowfish cipher:

25

26 import Crypto.Cipher.Types

27 import Crypto.Cipher

28

29 initBlowfish :: ByteString -> Blowfish

30 initBlowfish = either (error . show) cipherInit . makeKey

32 cryptKey key iv msg = encryptCBC ctx (makeIV iv) msg

33 where ctx = initBlowfish key

34

Blowfish.hs (git://github.com/vincenthz/hs-cryptocipher.git) Haskell · 61 lines

27 -- | 128 bit keyed blowfish state

28 newtype Blowfish128 = Blowfish128 Context

29

30 -- | 256 bit keyed blowfish state

31 newtype Blowfish256 = Blowfish256 Context

32

38 cipherKeySize _ = KeySizeRange 6 56

39 cipherInit k = either error Blowfish $ initBlowfish (toBytes k)

40

58 INSTANCE_CIPHER(Blowfish64, "blowfish64", 8)

59 INSTANCE_CIPHER(Blowfish128, "blowfish128", 16)

60 INSTANCE_CIPHER(Blowfish256, "blowfish256", 32)

61 INSTANCE_CIPHER(Blowfish448, "blowfish448", 56)

62

BlowFishCrypt.java (https://github.com/thanhvc/ofbiz.git) Java · 172 lines

36 */

37 public class BlowFishCrypt {

38

41 /**

42 * Creates a new BlowFishCrypt object.

43 * @param secretKeySpec A SecretKeySpec object.

44 */

45 public BlowFishCrypt(SecretKeySpec secretKeySpec) {

46 this.secretKeySpec = secretKeySpec;

52 */

53 public BlowFishCrypt(byte[] key) {

54 try {

143 String testString = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstufwxyz";

144 BlowFishCrypt c = new BlowFishCrypt(key);

145 byte[] encryptedBytes = c.encrypt(testString);

encrypted.py (git://github.com/RuudBurger/CouchPotatoServer.git) Python · 125 lines

6 encrypted and safely encoded for storage in a unicode column using the powerful

7 and secure Blowfish Cipher using a specified "secret" which can be passed into

8 the plugin at class declaration time.

34

35 from Crypto.Cipher import Blowfish

36 from elixir.statements import Statement

53 def encrypt_value(value, secret):

54 return Blowfish.new(secret, Blowfish.MODE_CFB) \

55 .encrypt(value).encode('string_escape')

57 def decrypt_value(value, secret):

58 return Blowfish.new(secret, Blowfish.MODE_CFB) \

59 .decrypt(value.decode('string_escape'))

BlowFishKey.java (https://github.com/ichiro101/l2adena-l2j-core.git) Java · 65 lines

22

23 import javax.crypto.Cipher;

24

30 */

31 public class BlowFishKey extends BaseSendablePacket

32 {

33 private static Logger _log = Logger.getLogger(BlowFishKey.class.getName());

34 /**

35 * @param blowfishKey

36 * @param publicKey

37 */

38 public BlowFishKey(byte[] blowfishKey, RSAPublicKey publicKey)

39 {

DESCoder.java (http://liweistudy.googlecode.com/svn/trunk/) Java · 139 lines

5

6 import javax.crypto.Cipher;

7 import javax.crypto.KeyGenerator;

15 * <pre>

16 * ?? DES?DESede(TripleDES,??3DES)?AES?Blowfish?RC2?RC4(ARCFOUR)

17 * DES key size must be equal to 56

19 * AES key size must be equal to 128, 192 or 256,but 192 and 256 bits may not be available

20 * Blowfish key size must be multiple of 8, and can only range from 32 to 448 (inclusive)

21 * RC2 key size must be between 40 and 1024 bits

38 * AES key size must be equal to 128, 192 or 256,but 192 and 256 bits may not be available

39 * Blowfish key size must be multiple of 8, and can only range from 32 to 448 (inclusive)

40 * RC2 key size must be between 40 and 1024 bits

65

66 // ??????????????AES?Blowfish??????????????????

67 // SecretKey secretKey = new SecretKeySpec(key, ALGORITHM);

__init__.py (https://bitbucket.org/adrians/cryptmd1) Python · 204 lines

4

5 from Crypto.Cipher import AES, ARC2, Blowfish, CAST, DES, DES3

6 from Crypto.Random import get_random_bytes

27 "arc2": {"key_sizes": None, "class": ARC2},

28 "blowfish": {"key_sizes": None, "class": Blowfish},

29 "cast": {"key_sizes": None, "class": CAST},

__init__.py (https://bitbucket.org/Behemot/university-rep.git) Python · 51 lines

32

33 Crypto.Cipher.AES Advanced Encryption Standard

34 Crypto.Cipher.ARC2 Alleged RC2

35 Crypto.Cipher.ARC4 Alleged RC4

36 Crypto.Cipher.Blowfish

37 Crypto.Cipher.CAST

38 Crypto.Cipher.DES The Data Encryption Standard. Very commonly used

39 in the past, but today its 56-bit keys are too small.

40 Crypto.Cipher.DES3 Triple DES.

41 Crypto.Cipher.XOR The simple XOR cipher.

44 __all__ = ['AES', 'ARC2', 'ARC4',

45 'Blowfish', 'CAST', 'DES', 'DES3',

46 'XOR'

BlowFishKey.java (http://l2emu.googlecode.com/svn/trunk/) Java · 60 lines

19

20 import javax.crypto.Cipher;

21

24 */

25 public final class BlowFishKey extends GameToLoginPacket

26 {

28

29 public BlowFishKey(byte[] decrypt, RSAPrivateKey privateKey)

30 {

50 {

51 _log.fatal("Error While decrypting blowfish key (RSA)", e);

52 }

common.py (https://bitbucket.org/galaxy/galaxy-central/) Python · 194 lines

9

10 from Crypto.Cipher import Blowfish

11

185 """

186 id_cipher = Blowfish.new( config_id_secret )

187 # Convert to string

JCEKeyGenerator.java (https://github.com/truedat101/fiskidagur.git) Java · 539 lines

11

12 import org.bouncycastle.crypto.CipherKeyGenerator;

13 import org.bouncycastle.crypto.KeyGenerationParameters;

196 /**

197 * Blowfish

198 */

199 public static class Blowfish

200 extends JCEKeyGenerator

201 {

202 public Blowfish()

203 {

204 super("Blowfish", 448, new CipherKeyGenerator());

205 }

__init__.py (https://bitbucket.org/djlawler/ironpycrypto) Python · 64 lines

32

33 Crypto.Cipher.AES Advanced Encryption Standard

34 Crypto.Cipher.ARC2 Alleged RC2

35 Crypto.Cipher.ARC4 Alleged RC4

36 Crypto.Cipher.Blowfish

37 Crypto.Cipher.CAST

38 Crypto.Cipher.DES The Data Encryption Standard. Very commonly used

39 in the past, but today its 56-bit keys are too small.

40 Crypto.Cipher.DES3 Triple DES.

41 Crypto.Cipher.XOR The simple XOR cipher.

49 import IronPyCrypto_Cipher_ARC4 as ARC4

50 import IronPyCrypto_Cipher_Blowfish as Blowfish

51 import IronPyCrypto_Cipher_CAST as CAST

nospamform.py (https://github.com/omat/kimlerdensin.git) Python · 40 lines

6 from django.conf import settings

7 from Crypto.Cipher import Blowfish

8 from base64 import b64encode, b64decode

12 def get_key():

13 cobj = Blowfish.new(settings.SECRET_KEY)

14 text = unicode(time())

29

30 cobj = Blowfish.new(settings.SECRET_KEY)

31 text = cobj.decrypt(b64decode(self.cleaned_data['key'])).rstrip('_')

Encryption.py (https://bitbucket.org/incubaid/pylabs-core/) Python · 49 lines ✨ Summary

This Python class, Encryption, provides a simple encryption method using Blowfish cipher. It generates a unique key based on the machine’s MAC address and uses this to encrypt and decrypt messages. The encrypted message is encoded in base64 and prefixed with a unique identifier to prevent decryption on different machines. This ensures that only the same machine can decrypt the message.

8 def __init__(self):

9 self.__blowfish = None

10

13 if not self.__blowfish:

14 from Crypto.Cipher import Blowfish

15 nics = filter(lambda x: x.startswith("eth") or x.startswith("wlan"), q.system.net.getNics())

20 mac = q.system.net.getMacAddress(nics[0])

21 self.__blowfish = Blowfish.new(mac)

22

23 return self.__blowfish

24 def encrypt(self, word):

KeyGen.java (http://aionknight.googlecode.com/svn/trunk/) Java · 103 lines

26 import java.security.spec.RSAKeyGenParameterSpec;

27 import javax.crypto.Cipher;

28 import javax.crypto.KeyGenerator;

33 /**

34 * Key generator. It generates keys or keyPairs for Blowfish and RSA

35 */

43 /**

44 * Key generator for blowfish

45 */

46 private static KeyGenerator blowfishKeyGen;

47

61

62 blowfishKeyGen = KeyGenerator.getInstance("Blowfish");

63

BlowFishAlgorithm.java (https://bitbucket.org/shubhamjain2908/test.git) Java · 133 lines

60 skeyString = new String(skey);

61 System.out.println("Blowfish Symmetric key = " + skeyString);

62 }

70 {

71 KeyGenerator kgen = KeyGenerator.getInstance("Blowfish");

72 SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");

92 SecretKeySpec skeySpec = new SecretKeySpec(raw, "Blowfish");

93 Cipher cipher = Cipher.getInstance("Blowfish");

94 cipher.init(Cipher.DECRYPT_MODE, skeySpec);

100 {

101 BlowFishAlgorithm bf = new BlowFishAlgorithm();

102 }

108 //import sun.misc.BASE64Encoder;

109 //public class BlowFishAlgorithm {

110 //

TestOfAssembly.java (git://pkgs.fedoraproject.org/java-1.7.0-openjdk) Java · 183 lines

32 import gnu.javax.crypto.assembly.TransformerException;

33 import gnu.javax.crypto.cipher.Blowfish;

34 import gnu.javax.crypto.cipher.IBlockCipher;

65

66 // build an OFB-Blowfish cascade

67 Cascade ofbBlowfish = new Cascade();

68 Object modeNdx = ofbBlowfish.append(Stage.getInstance(

69 ModeFactory.getInstance(

70 Registry.OFB_MODE, new Blowfish(), 8),

71 Direction.FORWARD));

77 testcase.asm = new Assembly();

78 testcase.asm.addPreTransformer(Transformer.getCascadeTransformer(ofbBlowfish));

79 testcase.asm.addPreTransformer(Transformer.getPaddingTransformer(pkcs7));

KeyGen.java (http://u3j-aion-beta.googlecode.com/svn/trunk/) Java · 99 lines

21

22 import javax.crypto.Cipher;

23 import javax.crypto.KeyGenerator;

29 /**

30 * Key generator. It generates keys or keyPairs for Blowfish and RSA

31 */

40 /**

41 * Key generator for blowfish

42 */

43 private static KeyGenerator blowfishKeyGen;

44

58

59 blowfishKeyGen = KeyGenerator.getInstance("Blowfish");

60

cipher-blowfish.cabal (git://github.com/vincenthz/hs-cryptocipher.git) Cabal · 55 lines

1 Name: cipher-blowfish

2 Version: 0.0.3

3 Description: Blowfish cipher primitives

4 License: BSD3

8 Maintainer: Vincent Hanquez <vincent@snarc.org>

9 Synopsis: Blowfish cipher

10 Category: Cryptography

21 , crypto-cipher-types >= 0.0.3 && < 0.1

22 Exposed-modules: Crypto.Cipher.Blowfish

23 Other-modules: Crypto.Cipher.Blowfish.Primitive

25

26 Test-Suite test-cipher-blowfish

27 type: exitcode-stdio-1.0

37 , crypto-cipher-tests

38 , cipher-blowfish

39

BlowfishCipherService.java (https://github.com/apache/shiro.git) Java · 92 lines

18 */

19 package org.apache.shiro.crypto.cipher;

20

21 /**

22 * {@code CipherService} using the {@code Blowfish} cipher algorithm for all encryption, decryption, and key operations.

23 * <p/>

24 * The Blowfish algorithm can support key sizes between {@code 32} and {@code 448} bits<b>*</b>, inclusive. However,

25 * modern cryptanalysis techniques render keys of 80 bits or less mostly worthless - use {@code 128} or more whenever

34 * <p/>

35 * <b>*</b> Generating and using Blowfish key sizes greater than 128 require installation of the

36 * <a href="http://java.sun.com/javase/downloads/index.jsp">Java Cryptography Extension (JCE) Unlimited Strength

40 */

41 public class BlowfishCipherService extends DefaultBlockCipherService {

42

__init__.py (https://bitbucket.org/Behemot/university-rep.git) Python · 33 lines

12

13 Crypto.Cipher.AES Advanced Encryption Standard

14 Crypto.Cipher.ARC2 Alleged RC2

15 Crypto.Cipher.ARC4 Alleged RC4

16 Crypto.Cipher.Blowfish

17 Crypto.Cipher.CAST

18 Crypto.Cipher.DES The Data Encryption Standard. Very commonly used

19 in the past, but today its 56-bit keys are too small.

20 Crypto.Cipher.DES3 Triple DES.

21 Crypto.Cipher.IDEA

22 Crypto.Cipher.RC5

23 Crypto.Cipher.XOR The simple XOR cipher.

crypto.py (https://github.com/olix0r/pub.git) Python · 48 lines

4 from Crypto import Util

5 from Crypto.Cipher import AES, Blowfish, DES3

6 from Crypto.PublicKey import RSA, DSA

cryptocipher.cabal (git://github.com/vincenthz/hs-cryptocipher.git) Cabal · 29 lines

20 , cipher-des >= 0.0 && < 0.1

21 , cipher-blowfish >= 0.0 && < 0.1

22 , cipher-camellia >= 0.0 && < 0.1

23 Exposed-modules: Crypto.Cipher

24 ghc-options: -Wall

GuvnorBootstrapConfiguration.java (https://github.com/bauna/guvnor.git) Java · 137 lines

22 import javax.annotation.PostConstruct;

23 import javax.crypto.Cipher;

24 import javax.crypto.spec.SecretKeySpec;

108 byte[] kbytes = "jaas is the way".getBytes();

109 SecretKeySpec key = new SecretKeySpec(kbytes, "Blowfish");

110

126

127 Cipher cipher = Cipher.getInstance("Blowfish");

128 cipher.init(Cipher.DECRYPT_MODE, key);

PickleRPCHandler.py (https://bitbucket.org/rfc1437/toolserver) Python · 83 lines

25 if hasCrypto:

26 from Crypto.Cipher import Blowfish

27 from Crypto.Util.randpool import RandomPool

46 s = decodestring(data)

47 b = Blowfish.new(key, Blowfish.MODE_CBC)

48 s = b.decrypt(s)

60 request._my_secret = genPassword()

61 b = Blowfish.new(request._my_secret, Blowfish.MODE_CBC)

62 res = b.encrypt(res+' '*(8-len(res)%8))

69 request._my_secret = genPassword()

70 b = Blowfish.new(request._my_secret, Blowfish.MODE_CBC)

71 res = b.encrypt(res+' '*(8-len(res)%8))

telnetenable.py (https://gitlab.com/fiddlerwoaroof/netgear-telnetenable) Python · 112 lines

24 from optparse import OptionParser

25 from Crypto.Cipher import Blowfish

26 from Crypto.Hash import MD5

29

30 # The version of Blowfish supplied for the telenetenable.c implementation

31 # assumes Big-Endian data, but the code does nothing to convert the

33 #

34 # So, since Crypto.Cipher.Blowfish seems to assume native endianness, we need

35 # to byteswap our buffer before and after encrypting it

68

69 return ByteSwap(Blowfish.new(secret_key, 1).encrypt(payload))

70

PasswordUtil.java (https://gitlab.com/kidaa/incubator-geode.git) Java · 124 lines

12

13 import javax.crypto.Cipher;

14 import javax.crypto.spec.SecretKeySpec;

17 * Generates an encrypted password, used by the gemfire encrypt-password

18 * command. Makes use of Blowfish algorithm to encrypt/decrypt password string

19 *

62 try {

63 SecretKeySpec key = new SecretKeySpec(init, "Blowfish");

64 Cipher cipher = Cipher.getInstance("Blowfish");

89 String toDecrypt = password.substring(10, password.length() - 1);

90 SecretKeySpec key = new SecretKeySpec(init, "Blowfish");

91 Cipher cipher = Cipher.getInstance("Blowfish");

crypto.py (https://github.com/weshayutin/rho.git) Python · 147 lines

16 # From the python-crypto package

17 from Crypto.Cipher import Blowfish

18

94

95 Uses the Blowfish algorithm. Plaintext will be padded if required.

96 """

97 obj = Blowfish.new(key, Blowfish.MODE_CBC)

98

107

108 Uses the Blowfish algorithm. Padding bytes (if present) will be removed.

109 """

110 obj = Blowfish.new(key, Blowfish.MODE_CBC)

111 decrypted_plaintext = obj.decrypt(ciphertext)

Blowfish.java (https://gitlab.com/Lepilov/fdroidclient.git) Java · 75 lines

2

3 import org.spongycastle.crypto.CipherKeyGenerator;

4 import org.spongycastle.crypto.engines.BlowfishEngine;

11

12 public final class Blowfish

13 {

14 private Blowfish()

15 {

22 {

23 super(new BlowfishEngine());

24 }

31 {

32 super(new CBCBlockCipher(new BlowfishEngine()), 64);

33 }

cryptocipher.cabal (git://github.com/vincenthz/hs-cryptocipher.git) Cabal · 94 lines

35 , cereal

36 Exposed-modules: Crypto.Cipher.RC4

37 Crypto.Cipher.AES

38 Crypto.Cipher.AES.Haskell

39 Crypto.Cipher.Blowfish

40 Crypto.Cipher.Camellia

41 Crypto.Cipher.RSA

42 Crypto.Cipher.DSA

43 Crypto.Cipher.DH

44 other-modules: Number.ModArithmetic

49 Number.Prime

50 Crypto.Cipher.ElGamal

51 ghc-options: -Wall

PickleRPCClient.py (https://bitbucket.org/rfc1437/toolserver) Python · 94 lines

27 try:

28 from Crypto.Cipher import Blowfish

29 hasCrypto = 1

64 data = compress(data)

65 b = Blowfish.new(obj.secret, Blowfish.MODE_CBC)

66 data = b.encrypt(data+' '*(8-len(data)%8))

76 data = decodestring(data)

77 b = Blowfish.new(obj.secret, Blowfish.MODE_CBC)

78 data = b.decrypt(data)

BlowfishEncryptor.java (https://gitlab.com/philip-kissme/plugin-framework.git) Java · 113 lines

10

11 import javax.crypto.Cipher;

12 import javax.crypto.spec.SecretKeySpec;

22 */

23 public class BlowfishEncryptor implements Encryptor {

24

25 // private static Logger logger = LoggerFactory.getLogger(BlowfishEncryptor.class);

26

27 private static String algorithm = "Blowfish/ECB/ZeroBytePadding";

28

88 //

89 // BlowfishEncryptor encryptor = new BlowfishEncryptor();

90 //

util.py (https://bitbucket.org/galaxy/galaxy-central/) Python · 33 lines

1 from Crypto.Cipher import Blowfish

2

13 user_hash = ( "!" * ( 8 - len( user_hash ) % 8 ) ) + user_hash

14 cipher = Blowfish.new( str( dataset.create_time ) )

15 user_hash = cipher.encrypt( user_hash ).encode( 'hex' )

27 else:

28 cipher = Blowfish.new( str( dataset.create_time ) )

29 user_id = cipher.decrypt( user_hash.decode( 'hex' ) ).lstrip( "!" )

License.java (http://xerela.googlecode.com/svn/trunk/) Java · 77 lines

25

26 import javax.crypto.Cipher;

27 import javax.crypto.CipherOutputStream;

36 private static final String PASS_PHRASE = "XerelaPassPhrase";

37 private static final String ALGORITHM = "Blowfish";

38

BlowFishKey.java (http://l2emu.googlecode.com/svn/trunk/) Java · 46 lines

19

20 import javax.crypto.Cipher;

21

24 */

25 public final class BlowFishKey extends GameServerBasePacket

26 {

27 public BlowFishKey(byte[] blowfishKey, RSAPublicKey publicKey)

28 {

34 rsaCipher.init(Cipher.ENCRYPT_MODE, publicKey);

35 encrypted = rsaCipher.doFinal(blowfishKey);

36

41 {

42 _log.fatal("Error While encrypting blowfish key for transmision (Crypt error)", e);

43 }

Blowfish.patch (http://tatami.googlecode.com/svn/trunk/) Patch · 42 lines ✨ Summary

The patch code updates the Blowfish encryption algorithm to handle characters outside the ASCII range (128 and below) by converting them to a value within the 0-255 range, ensuring proper encryption and decryption of all input data.

1 Index: Blowfish.js

2 ===================================================================

3 --- Blowfish.js (revision 15563)

4 +++ Blowfish.js (working copy)

5 @@ -343,14 +343,14 @@

6 var cipher=[], count=plaintext.length >> 3, pos=0, o={}, isCBC=(mode==dojox.encoding.crypto.cipherModes.CBC);

7 var vector={left:iv.left||null, right:iv.right||null};

CriptografiaService.java (https://github.com/rafabene/PoCs.git) Java · 97 lines

9

10 import javax.crypto.Cipher;

11 import javax.crypto.spec.SecretKeySpec;

53 byte[] kbytes = chave.getBytes();

54 SecretKeySpec key = new SecretKeySpec(kbytes, "Blowfish");

55

59 try {

60 Cipher cipher = Cipher.getInstance("Blowfish");

61 cipher.init(Cipher.DECRYPT_MODE, key);

71 byte[] kbytes = chave.getBytes();

72 SecretKeySpec key = new SecretKeySpec(kbytes, "Blowfish");

73

74 try {

75 Cipher cipher = Cipher.getInstance("Blowfish");

76 cipher.init(Cipher.ENCRYPT_MODE, key);

Benchmarks.hs (git://github.com/vincenthz/hs-cryptocipher.git) Haskell · 114 lines

15

16 import qualified Crypto.Cipher.AES.Haskell as AES

17 #ifdef HAVE_AESNI

18 import qualified Crypto.Cipher.AES.X86NI as AESNI

19 #endif

20 import qualified Crypto.Cipher.RC4 as RC4

21 import qualified Crypto.Cipher.Blowfish as Blowfish

22 import qualified Crypto.Cipher.Camellia as Camellia

48 (Right blowfishKey) = Blowfish.initKey $ B.empty

49 blowfishEncrypt = Blowfish.encrypt blowfishKey

50

95 [ ("RC4" , rc4Encrypt)

96 , ("Blowfish" , blowfishEncrypt)

97 , ("Camellia128", camelliaEncrypt128)

BlowFishKey.java (https://bitbucket.org/Rofgar/l2j_server.git) Java · 62 lines

24

25 import javax.crypto.Cipher;

26

31 */

32 public class BlowFishKey extends BaseSendablePacket

33 {

34 private static Logger _log = Logger.getLogger(BlowFishKey.class.getName());

35

36 /**

37 * @param blowfishKey

38 * @param publicKey

39 */

40 public BlowFishKey(byte[] blowfishKey, RSAPublicKey publicKey)

41 {

BlowfishCipher.java (https://github.com/ebonnet/Silverpeas-Core.git) Java · 128 lines

40 *

41 * This implementation wraps the Blowfish cipher provided in the Java Cryptography API and it

42 * performs the redundant operations in the encryption and in the decryption.

46 private final javax.crypto.Cipher cipher;

47 private BlowfishKey blowfishKey = null;

48

50 blowfishKey = new BlowfishKey();

51 cipher = javax.crypto.Cipher.getInstance(CryptographicAlgorithmName.Blowfish.name());

52 }

60 public CryptographicAlgorithmName getAlgorithmName() {

61 return CryptographicAlgorithmName.Blowfish;

62 }

73 } else {

74 key = new BlowfishKey(keyCode.getRawKey());

75 }

crypt.py (https://github.com/omat/kimlerdensin.git) Python · 111 lines

3 from django.contrib import contenttypes

4 from Crypto.Cipher import Blowfish

5 from base64 import *

23 def cryptString( plain ):

24 obj=Blowfish.new( settings.SECRET_KEY, Blowfish.MODE_ECB)

25 randstring = open("/dev/urandom").read(12)

39 def decryptString( cipher ):

40 obj=Blowfish.new( settings.SECRET_KEY, Blowfish.MODE_ECB)

41 try:

settings.py (https://github.com/mpessas/pimme.git) Python · 90 lines

9 import ConfigParser

10 from Crypto.Cipher import Blowfish, AES

11 import secret_key

29 default['keyring'] = 'user'

30 default['algorithm'] = 'Blowfish'

31 return default

58 alg = config.get('Cryptography', 'algorithm')

59 if alg == 'Blowfish':

60 CipherAlgorithm = Blowfish

79 # Encryption algorithm to use.

80 # Possible values: Blowfish, AES

81 algorithm = Blowfish

LicenseElf.java (http://xerela.googlecode.com/svn/trunk/) Java · 93 lines

27

28 import javax.crypto.Cipher;

29 import javax.crypto.CipherInputStream;

40 private static final String PASS_PHRASE = "XerelaPassPhrase";

41 private static final String ALGORITHM = "Blowfish";

42 private static License license;

BeanTypeListenerTest.java (https://github.com/apache/shiro.git) Java · 130 lines

31 import org.apache.shiro.aop.DefaultAnnotationResolver;

32 import org.apache.shiro.crypto.cipher.BlowfishCipherService;

33 import org.apache.shiro.guice.aop.ShiroAopModule;

70 assertTrue(BeanTypeListener.MATCHER.matches(TypeLiteral.get(DefaultAnnotationResolver.class)));

71 assertTrue(BeanTypeListener.MATCHER.matches(TypeLiteral.get(BlowfishCipherService.class)));

72 }

EncryptUtil.java (https://github.com/vvakame/TwitHubBridge.git) Java · 43 lines

7 import javax.crypto.BadPaddingException;

8 import javax.crypto.Cipher;

9 import javax.crypto.IllegalBlockSizeException;

15 public class EncryptUtil {

16 private static final String ALGORITHM = "Blowfish";

17

login_details.py (https://github.com/theosp/finance-manager.git) Python · 126 lines

8

9 from Crypto.Cipher import Blowfish

10 import crack

33 def _encrypt(encryption_key, string):

34 cipher_obj = Blowfish.new(encryption_key)

35 return cipher_obj.encrypt(string)

37 def _decrypt(encryption_key, string):

38 cipher_obj = Blowfish.new(encryption_key)

39 return cipher_obj.decrypt(string)

BlockCipherFactory.java (https://code.google.com/p/sshtunnel/) Java · 110 lines

35 ciphers.addElement(new CipherEntry("aes192-cbc", 16, 24,

36 "com.trilead.ssh2.crypto.cipher.AES"));

37 ciphers.addElement(new CipherEntry("aes128-cbc", 16, 16,

38 "com.trilead.ssh2.crypto.cipher.AES"));

39 ciphers.addElement(new CipherEntry("blowfish-cbc", 8, 16,

40 "com.trilead.ssh2.crypto.cipher.BlowFish"));

41

42 ciphers.addElement(new CipherEntry("aes256-ctr", 16, 32,

43 "com.trilead.ssh2.crypto.cipher.AES"));

44 ciphers.addElement(new CipherEntry("aes192-ctr", 16, 24,

48 ciphers.addElement(new CipherEntry("blowfish-ctr", 8, 16,

49 "com.trilead.ssh2.crypto.cipher.BlowFish"));

50