100+ results for 'crypto.cip blowfish'

Not the results you expected?

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

1 package com.sishuok.es.common.utils.security;

2

3 import javax.crypto.Cipher;

4 import javax.crypto.SecretKey;

5 import javax.crypto.spec.SecretKeySpec;

11 * <p/>

12 * <pre>

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

14 * DES key size must be equal to 56

15 * DESede(TripleDES) key size must be equal to 112 or 168

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

19 * RC4(ARCFOUR) key size must be between 40 and 1024 bits

SecureIdentityLoginModule.java (https://github.com/xie-summer/zdal.git) Java · 156 lines

10

11 import javax.crypto.BadPaddingException;

12 import javax.crypto.Cipher;

13 import javax.crypto.IllegalBlockSizeException;

14 import javax.crypto.NoSuchPaddingException;

68 IllegalBlockSizeException,

69 BadPaddingException {

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

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

110 BadPaddingException,

111 IllegalBlockSizeException {

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

113 BigInteger n = new BigInteger(secret, 16);

114 byte[] encoding = n.toByteArray();

124 }

125 }

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

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

128 byte[] decode = cipher.doFinal(encoding);

GuvnorBootstrapConfiguration.java (https://github.com/bounty12281/guvnor.git) Java · 126 lines

20 import java.util.HashMap;

21 import java.util.Map;

22 import javax.crypto.Cipher;

23 import javax.crypto.spec.SecretKeySpec;

24 import javax.enterprise.context.ApplicationScoped;

96 try {

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

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

99

100 BigInteger n = new BigInteger(secret, 16);

114 }

115

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

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

118 byte[] decode = cipher.doFinal(encoding);

awalletextractor.py (https://github.com/jwal/jwallib-retired.git) Python · 127 lines

6 try:

7 from Crypto.Hash import SHA256, SHA

8 from Crypto.Cipher import AES, Blowfish, DES3

9 except ImportError, e:

10 raise ImportError("Try 'sudo apt-get install python-crypto': %s" % (e,))

20 128,

21 )),

22 (Blowfish, (

23 256,

24 192,

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

223 // Pass Phrase.

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

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

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

227

228 // Create encrypter/decrypter class

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

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

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

232

238 // Decrypt the string

239 String desDecrypted = desEncrypter.decrypt( desEncrypted );

240 String blowfishDecrypted = blowfishEncrypter.decrypt( blowfishEncrypted );

241 String desedeDecrypted = desedeEncrypter.decrypt( desedeEncrypted );

242

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

28 import java.util.Arrays;

29 import java.security.NoSuchAlgorithmException;

30 import javax.crypto.Cipher;

31 import javax.crypto.NoSuchPaddingException;

32

33 public class SilverCryptFactorySymetric {

34

35 public static final String ALGORITHM = "Blowfish";

36 /**

37 * Singleton managing the keyring.

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

1 # -*- coding: utf-8 -*-

2 #

3 # Cipher/Blowfish.py : Blowfish

4 #

5 # ===================================================================

39 >>> key = b'An arbitrarily long key'

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

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

42 >>> plaintext = b'docendo discimus '

43 >>> plen = bs - divmod(len(plaintext),bs)[1]

46 >>> msg = iv + cipher.encrypt(plaintext + padding)

47

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

49

50 :undocumented: __revision__, __package__

55 from Crypto.Cipher import blockalgo

56 from Crypto.Cipher import _Blowfish

57

58 class BlowfishCipher (blockalgo.BlockAlgo):

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

21 import java.util.Map;

22 import javax.annotation.PostConstruct;

23 import javax.crypto.Cipher;

24 import javax.crypto.spec.SecretKeySpec;

25 import javax.enterprise.context.ApplicationScoped;

107 try {

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

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

110

111 BigInteger n = new BigInteger(secret, 16);

125 }

126

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

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

129 byte[] decode = cipher.doFinal(encoding);

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

1 package org.bouncycastle.jcajce.provider.symmetric;

2

3 import org.bouncycastle.crypto.CipherKeyGenerator;

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

10 import org.bouncycastle.jcajce.provider.util.AlgorithmProvider;

11

12 public final class Blowfish

13 {

14 private Blowfish()

21 public ECB()

22 {

23 super(new BlowfishEngine());

24 }

25 }

30 public CBC()

31 {

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

33 }

34 }

__init__.py (https://bitbucket.org/nicste/ballaxy.git) Python · 57 lines

4 pkg_resources.require( "pycrypto" )

5

6 from Crypto.Cipher import Blowfish

7 from Crypto.Util.randpool import RandomPool

8 from Crypto.Util import number

34 def __init__( self, **config ):

35 self.id_secret = config['id_secret']

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

37 def encode_id( self, obj_id ):

38 # Convert to string

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

33 import javax.crypto.spec.*;

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;}

40 public int getBlockSize(){return bsize;}

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),

61 skeySpec, new IvParameterSpec(iv));

62 }

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

6 import java.io.OutputStream;

7

8 import javax.crypto.Cipher;

9 import javax.crypto.spec.SecretKeySpec;

10 import javax.mail.internet.MimeUtility;

15

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);

21

22 return encodeBase64(cipher.doFinal(text.getBytes()));

50

51 SecretKeySpec sksSpec =

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

53

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

CipherWithWrappingSpi.java (https://github.com/Morriar/ProxyJDK.git) Java · 261 lines

37 import java.security.spec.InvalidKeySpecException;

38

39 import javax.crypto.Cipher;

40 import javax.crypto.CipherSpi;

45

46 /**

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

48 * implementation of the methods for wrapping and unwrapping

49 * keys.

52 *

53 *

54 * @see javax.crypto.CipherSpi

55 * @see BlowfishCipher

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

27 '''

28

29 from Crypto.Cipher import Blowfish

30 from elixir.statements import Statement

31 from sqlalchemy.orm import MapperExtension, EXT_CONTINUE

40

41 def encrypt_value(value, secret):

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

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

44

45 def decrypt_value(value, secret):

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

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

48

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

7

8 import javax.crypto.BadPaddingException;

9 import javax.crypto.Cipher;

10 import javax.crypto.IllegalBlockSizeException;

11 import javax.crypto.NoSuchPaddingException;

23 public final class TestLadderEncoding {

24

25 private static final String ALGORITHM = "Blowfish";

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

33 * method is only used to encrypt the password for the .properties files

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

40 * during the execution of this method. The problem could be that the

ERXAbstractBlowfishCrypter.java (https://github.com/hprange/wonder.git) Java · 222 lines

11

12 /**

13 * ERXAbstractBlowfishCrypter is a blowfish implementation of the crypter

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

70 protected Cipher createBlowfishCipher(int mode) {

71 try {

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

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

96

97 /**

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

99 * cipher.

100 *

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

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

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

178 * the original string is. For one-way encryption look at methods dealing

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

1 package gnu.javax.crypto.cipher;

2 class WeakKeyException {

3 }

349 int DEFAULT_BLOCK_SIZE;

350 }

351 class Blowfish {

352 class Block {

353 int right;

BlockCipherFactory.java (https://bitbucket.org/zielmicha/connectbot.git) Java · 115 lines

1

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

3

4 import java.util.Vector;

34 /* Higher Priority First */

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"));

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

46 ciphers.addElement(new CipherEntry("3des-ctr", 8, 24, "com.trilead.ssh2.crypto.cipher.DESede"));

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

2

3 /**

4 * Blowfish.java version 1.00.00

5 *

6 * Code Written by k2r (k2r.contact@gmail.com)

31 import java.io.UnsupportedEncodingException;

32 import java.security.InvalidKeyException;

33 import javax.crypto.Cipher;

34 import javax.crypto.spec.SecretKeySpec;

35 import org.slf4j.Logger;

36 import org.slf4j.LoggerFactory;

37

38 public class Blowfish

39 {

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

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

19 from random import randrange

20 import base64

21 from Crypto.Cipher import Blowfish

22 from django.conf import settings

23

26 if not pwd:

27 pwd = getattr(settings, 'SECRET_KEY')

28 self.__cipher = Blowfish.new(pwd)

29 def encrypt(self, text):

30 ciphertext = self.__cipher.encrypt(self.__pad_file(text))

38 cleartext = self.__depad_file(self.__cipher.decrypt(ciphertext))

39 return cleartext

40 # Blowfish cipher needs 8 byte blocks to work with

41 def __pad_file(self, text):

42 pad_bytes = 8 - (len(text) % 8)

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

31 import java.util.Locale;

32

33 import javax.crypto.Cipher;

34

35 public class Turkish {

41 System.out.println(Cipher.getInstance("RSA/ECB/PKCS1PADDING"));

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

47 System.out.println("OK");

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

32 class Crypto:

33

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

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

36 _Modes = ['ECB', 'CBC', 'CFB', 'OFB', 'PGP'] #CTR needs 4 args

62 #avoid Memmory Error

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')

JCEKeyGenerator.java (https://github.com/xl8or/-.git) Java · 369 lines

8 import javax.crypto.SecretKey;

9 import javax.crypto.spec.SecretKeySpec;

10 import myorg.bouncycastle.crypto.CipherKeyGenerator;

11 import myorg.bouncycastle.crypto.KeyGenerationParameters;

12 import myorg.bouncycastle.crypto.generators.DESKeyGenerator;

78 }

79

80 public static class Blowfish extends JCEKeyGenerator {

81

82 public Blowfish() {

83 CipherKeyGenerator var1 = new CipherKeyGenerator();

84 super("Blowfish", 128, var1);

85 }

86 }

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

1 package org.bouncycastle.jce.provider;

2

3 import org.bouncycastle.crypto.CipherKeyGenerator;

4 import org.bouncycastle.crypto.KeyGenerationParameters;

5 import org.bouncycastle.crypto.generators.DESKeyGenerator;

173

174 /**

175 * Blowfish

176 */

177 public static class Blowfish

178 extends JCEKeyGenerator

179 {

180 public Blowfish()

181 {

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

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

4 """

5

6 from Crypto.Cipher import Blowfish

7 from datetime import datetime

8 from decimal import Decimal

110 def _decrypt_code(code):

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)

118 def _encrypt_code(code):

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)

CipherFactory.java (https://github.com/GunioRobot/MI424WR_GEN2_Rev_E-F.git) Java · 150 lines

1 package gnu.crypto.cipher;

2

3 // ----------------------------------------------------------------------------

90 if (name.equalsIgnoreCase(ANUBIS_CIPHER)) {

91 result = new Anubis();

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

93 result = new Blowfish();

132 HashSet hs = new HashSet();

133 hs.add(ANUBIS_CIPHER);

134 hs.add(BLOWFISH_CIPHER);

135 hs.add(DES_CIPHER);

136 hs.add(KHAZAD_CIPHER);

SecretUtils.java (https://github.com/jlcool/aliossflutter.git) Java · 89 lines

5 import java.io.UnsupportedEncodingException;

6

7 import javax.crypto.Cipher;

8 import javax.crypto.SecretKey;

9 import javax.crypto.spec.SecretKeySpec;

SecretUtils.java (https://github.com/AllenCoder/SuperUtils.git) Java · 112 lines

20 import java.io.UnsupportedEncodingException;

21 import java.security.NoSuchAlgorithmException;

22 import javax.crypto.Cipher;

23 import javax.crypto.NoSuchPaddingException;

24 import javax.crypto.SecretKey;

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

1 import pkg_resources

2 pkg_resources.require( "pycrypto" )

3 from Crypto.Cipher import Blowfish

4

5 def encode_dataset_user( trans, dataset, user ):

13 # Pad to a multiple of 8 with leading "!"

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' )

17 return dataset_hash, user_hash

26 user = None

27 else:

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

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

30 user = trans.sa_session.query( trans.app.model.User ).get( int( user_id ) )

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

1 -- |

2 -- Module : Crypto.Cipher

3 -- License : BSD-style

4 -- Maintainer : Vincent Hanquez <vincent@snarc.org>

11 -- A simplified example (with simplified error handling):

12 --

13 -- > import Crypto.Cipher

14 -- > import Data.ByteString (ByteString)

15 -- > import qualified Data.ByteString as B

44 -- * Cipher implementations

45 , AES128, AES192, AES256

46 , Blowfish, Blowfish64, Blowfish128, Blowfish256, Blowfish448

47 , DES

48 , DES_EEE3, DES_EDE3, DES_EEE2, DES_EDE2

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

54 import Crypto.Cipher.Blowfish

55 import Crypto.Cipher.DES

Obfuscator.java (https://github.com/metlos/RHQ-old.git) Java · 121 lines

25

26 import javax.crypto.BadPaddingException;

27 import javax.crypto.Cipher;

28 import javax.crypto.IllegalBlockSizeException;

29 import javax.crypto.NoSuchPaddingException;

43

44 private static final byte[] KEY = "jaas is the way".getBytes();

45 public static final String ALGORITHM = "Blowfish";

46

47 //no instances, please

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

22 import java.io.IOException;

23

24 import javax.crypto.Cipher;

25 import javax.crypto.CipherInputStream;

26 import javax.crypto.CipherOutputStream;

27 import javax.crypto.spec.SecretKeySpec;

28

33 import com.esotericsoftware.kryo.io.Output;

34

35 /** Encrypts data using the blowfish cipher.

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

37 public class BlowfishSerializer extends Serializer {

39 static private SecretKeySpec keySpec;

40

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

42 this.serializer = serializer;

43 keySpec = new SecretKeySpec(key, "Blowfish");

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

21 import org.apache.log4j.Logger;

22

23 import javax.crypto.Cipher;

24 import javax.crypto.KeyGenerator;

25 import javax.crypto.SecretKey;

29

30 /**

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

32 *

33 * @author -Nemesiss-

57 log.info("Initializing Key Generator...");

58

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

60

61 KeyPairGenerator rsaKeyPairGenerator = KeyPairGenerator.getInstance("RSA");

__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.

4 pkg_resources.require( "pycrypto" )

5

6 from Crypto.Cipher import Blowfish

7 from Crypto.Util.randpool import RandomPool

8 from Crypto.Util import number

36 def __init__( self, **config ):

37 self.id_secret = config['id_secret']

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

39

40 def encode_id( self, obj_id ):

idencoding.py (https://github.com/galaxyproject/galaxy.git) Python · 128 lines

3 import logging

4

5 from Crypto.Cipher import Blowfish

6 from Crypto.Random import get_random_bytes

7

24 id_secret = config['id_secret']

25 self.id_secret = id_secret

26 self.id_cipher = Blowfish.new(smart_str(self.id_secret), mode=Blowfish.MODE_ECB)

27

28 per_kind_id_secret_base = config.get('per_kind_id_secret_base', self.id_secret)

117 assert len(key) < 15, KIND_TOO_LONG_MESSAGE

118 secret = self.secret_base + "__" + key

119 return Blowfish.new(_last_bits(secret), mode=Blowfish.MODE_ECB)

120

121

GnuCrypto.java (https://bitbucket.org/pizzafactory/pf-gcc.git) Java · 598 lines

40

41 import gnu.java.security.Registry;

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

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

44

73 gnu.javax.crypto.jce.cipher.ARCFourSpi.class.getName());

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());

79 put("Cipher.DES ImplementedIn", "Software");

111 put("Cipher.PBEWithHMacHavalAndAnubis",

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());

Crypto.java (https://github.com/openjdk/jdk.git) Java · 112 lines

28 import java.util.concurrent.TimeUnit;

29 import javax.crypto.BadPaddingException;

30 import javax.crypto.Cipher;

31 import javax.crypto.IllegalBlockSizeException;

32 import javax.crypto.KeyGenerator;

58 private int length;

59

60 @Param({"AES", "Blowfish", "DES", "DESede"})

61 private String cipherName;

62

BlockCipherFactory.java (https://github.com/connectbot/sshlib.git) Java · 103 lines

1

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

3

4 import java.lang.reflect.Constructor;

35 /* Higher Priority First */

36

37 ciphers.add(new CipherEntry("aes256-ctr", 16, 32, "com.trilead.ssh2.crypto.cipher.AES$CTR"));

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

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

40

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

42 ciphers.add(new CipherEntry("aes128-cbc", 16, 16, "com.trilead.ssh2.crypto.cipher.AES$CBC"));

43 ciphers.add(new CipherEntry("blowfish-cbc", 8, 16, "com.trilead.ssh2.crypto.cipher.BlowFish$CBC"));

44

45 ciphers.add(new CipherEntry("3des-ctr", 8, 24, "com.trilead.ssh2.crypto.cipher.DESede$CTR"));

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

15 import java.security.spec.KeySpec;

16

17 import javax.crypto.Cipher;

18 import javax.crypto.KeyGenerator;

19 import javax.crypto.SecretKey;

24 * bytes. This can be set directly on the strategy or a keyFactory can be specified.

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.

28 *

36 {

37

38 public static final String DEFAULT_ALGORITHM = "Blowfish";

39

40 private byte[] key;

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

5 import org.bouncycastle.crypto.params.KeyParameter;

6

7 import javax.crypto.Cipher;

8 import javax.crypto.SecretKey;

9 import javax.crypto.spec.IvParameterSpec;

69 else if (dekAlgName.startsWith("BF-"))

70 {

71 alg = "Blowfish";

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

73 }

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

34 def __init__(self, key):

35 Cipher.__init__(self, key)

36 self.__cipher = Blowfish(key)

37

38 def encrypt(self, text):

59 return self.__depad_text(cleartext)

60

61 # Blowfish cipher needs 8 byte blocks to work with

62 def __pad_text(self, text):

63 pad_bytes = 8 - (len(text) % 8)

114

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

46 name = cipher.__name__.split('.')[-1]

47 part.__name__ = name.lower()

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

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

50 "creating a cipher using the {} algorithm. Arguments have the same "

54

55 aes = _setup_cipher(_AES)

56 blowfish = _setup_cipher(_Blowfish)

57 cast = _setup_cipher(_CAST)

58 des = _setup_cipher(_DES)

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

27

28 import javax.crypto.BadPaddingException;

29 import javax.crypto.Cipher;

30 import javax.crypto.IllegalBlockSizeException;

31 import javax.crypto.NoSuchPaddingException;

34 import org.columba.ristretto.coder.Base64;

35

36 public class Blowfish {

37 private static final Logger LOG = Logger

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

41 45, 25, 38, 70, -17, 40, 36, -23 };

42

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

44

45 public static String encrypt(char[] source) {

__init__.py (https://gitlab.com/sisfs/G_Music) Python · 83 lines

40 Module name Type Description

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.

GnuCrypto.java (https://github.com/sethish-mirrors/MI424WR_GEN2_Rev_E-F.git) Java · 471 lines

85 put("Cipher.ARCFOUR", gnu.crypto.jce.cipher.ARCFourSpi.class.getName());

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

87 put("Cipher.BLOWFISH", gnu.crypto.jce.cipher.BlowfishSpi.class.getName());

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

199 put("Cipher.PBEWithHMacSHA1AndBlowfish",

200 gnu.crypto.jce.cipher.PBES2.HMacSHA1.Blowfish.class.getName());

201 put("Cipher.PBEWithHMacSHA1AndCast5",

202 gnu.crypto.jce.cipher.PBES2.HMacSHA1.Cast5.class.getName());

343 // Simple SecretKeyFactory implementations.

344 put ("SecretKeyFactory.Anubis", gnu.crypto.jce.key.AnubisSecretKeyFactoryImpl.class.getName());

345 put ("SecretKeyFactory.Blowfish", gnu.crypto.jce.key.BlowfishSecretKeyFactoryImpl.class.getName());

346 put ("SecretKeyFactory.Cast5", gnu.crypto.jce.key.Cast5SecretKeyFactoryImpl.class.getName());

347 put ("SecretKeyFactory.DES", gnu.crypto.jce.key.DESSecretKeyFactoryImpl.class.getName());

377

378 put("Mac.OMAC-ANUBIS", gnu.crypto.jce.mac.OMacAnubisImpl.class.getName());

379 put("Mac.OMAC-BLOWFISH", gnu.crypto.jce.mac.OMacBlowfishImpl.class.getName());

380 put("Mac.OMAC-CAST5", gnu.crypto.jce.mac.OMacCast5Impl.class.getName());

381 put("Mac.OMAC-DES", gnu.crypto.jce.mac.OMacDESImpl.class.getName());

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

4 """

5

6 from Crypto.Cipher import Blowfish

7 from datetime import datetime

8 from decimal import Decimal

110 """Decrypt code encrypted by _encrypt_code"""

111 secret_key = settings.SECRET_KEY

112 encryption_object = Blowfish.new(secret_key)

113 # strip padding from decrypted credit card number

114 return encryption_object.decrypt(base64.b64decode(code)).rstrip('X')

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

118 secret_key = settings.SECRET_KEY

119 encryption_object = Blowfish.new(secret_key)

120 # block cipher length must be a multiple of 8

121 padding = ''

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

3

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

9

48

49 main = defaultMain

50 [ testBlockCipher kats (undefined :: Blowfish64)

51 ]

52

models.py (https://github.com/jtslade/satchmo-svn.git) Python · 128 lines

4 """

5

6 from Crypto.Cipher import Blowfish

7 from datetime import datetime

8 from django.conf import settings

114 """Decrypt code encrypted by _encrypt_code"""

115 secret_key = settings.SECRET_KEY

116 encryption_object = Blowfish.new(secret_key)

117 # strip padding from decrypted credit card number

118 return encryption_object.decrypt(base64.b64decode(code)).rstrip('X')

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

122 secret_key = settings.SECRET_KEY

123 encryption_object = Blowfish.new(secret_key)

124 # block cipher length must be a multiple of 8

125 padding = ''

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

6

7 import scala.util.Random

8 import javax.crypto.Cipher

9 import javax.crypto.KeyGenerator

10 import javax.crypto.SecretKey

28 newSecretKey()

29

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

31

32 peerPubKey match {

36 setPeerPubKey(BigInt(peerPubKey.get))

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

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

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

49 }

50

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

52

53 peerPubKey match {

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

3 * Please refer to the LICENSE.txt for licensing details.

4 */

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

6

7 import java.util.ArrayList;

38 {

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"));

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

50 ciphers.add(new CipherEntry("3des-ctr", 8, 24, "ch.ethz.ssh2.crypto.cipher.DESede"));

JCEKeyGenerator.java (https://github.com/lems111/Intercept-CM6-Kernel.git) Java · 541 lines

10 import javax.crypto.spec.SecretKeySpec;

11

12 import org.bouncycastle.crypto.CipherKeyGenerator;

13 import org.bouncycastle.crypto.KeyGenerationParameters;

14 import org.bouncycastle.crypto.generators.DESKeyGenerator;

195

196 /**

197 * Blowfish

198 */

199 public static class Blowfish

200 extends JCEKeyGenerator

201 {

202 public Blowfish()

203 {

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

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

4 """

5

6 from Crypto.Cipher import Blowfish as crypto

7 import simplejson as json

8 from getpass import getpass

Crypto.java (https://bitbucket.org/gustavopuga/foundation.git) Java · 146 lines

3 import java.security.NoSuchAlgorithmException;

4

5 import javax.crypto.Cipher;

6 import javax.crypto.KeyGenerator;

7 import javax.crypto.SecretKey;

19 public static final String ALGORITHM_AES = "AES";

20

21 public static final String ALGORITHM_BLOWFISH = "Blowfish";

22

23 public static final String ALGORITHM_DES = "DES";

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

6 import galaxy.exceptions

7

8 from Crypto.Cipher import Blowfish

9 from Crypto.Util.randpool import RandomPool

10 from Crypto.Util import number

39 def __init__( self, **config ):

40 self.id_secret = config['id_secret']

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

42

43 per_kind_id_secret_base = config.get( 'per_kind_id_secret_base', self.id_secret )

128

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

4 """

5

6 from Crypto.Cipher import Blowfish

7 from django.conf import settings

8 from django.db import models

58 # Must remember to save it after calling!

59 secret_key = settings.SECRET_KEY

60 encryption_object = Blowfish.new(secret_key)

61 # block cipher length must be a multiple of 8

62 padding = ''

68 def _decryptCC(self):

69 secret_key = settings.SECRET_KEY

70 encryption_object = Blowfish.new(secret_key)

71 # strip padding from decrypted credit card number

72 ccnum = encryption_object.decrypt(base64.b64decode(self.encryptedCC)).rstrip('X')

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

5

6 import javax.crypto.BadPaddingException;

7 import javax.crypto.Cipher;

8 import javax.crypto.IllegalBlockSizeException;

9 import javax.crypto.NoSuchPaddingException;

16 */

17 public class Cryption {

18 private static final String TRANSFORMATION = "Blowfish";

19

20 public Cryption() {}

26 try {

27 Cipher cipher = Cipher.getInstance(TRANSFORMATION);

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

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

30 } catch (NoSuchAlgorithmException e) {

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

29 import java.util.Arrays;

30 import java.security.NoSuchAlgorithmException;

31 import javax.crypto.Cipher;

32 import javax.crypto.NoSuchPaddingException;

33

34 public class SilverCryptFactorySymetric {

35

36 public static final String ALGORITHM = "Blowfish";

37 /**

38 * Singleton managing the keyring.

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

4

5

6 from Crypto.Cipher import Blowfish

7 from base64 import *

8 import random

11

12 def cryptString( secret, plain ):

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

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

15 randstring = str.join( '', random.sample('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',12) )

29

30 def decryptString( secret, cipher ):

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

32 try:

33 ciph = b32decode( cipher )

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

11 import org.junit.Test;

12

13 import javax.crypto.Cipher;

14 import java.security.*;

15 import java.security.interfaces.RSAPrivateKey;

161 public void testBlowfishCipherService() {

162 BlowfishCipherService blowfishCipherService = new BlowfishCipherService();

163 blowfishCipherService.setKeySize(128);

164

165 //生成key

166 Key key = blowfishCipherService.generateNewKey();

167

168 String text = "hello";

169

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());

threaded.py (https://github.com/niwibe/django-logstream.git) Python · 69 lines

10 import zmq, copy

11

12 from Crypto.Cipher import Blowfish

13 from Crypto.Hash import SHA

14

42

43 def _loop(self):

44 self.cipher = Blowfish.new(settings.SECRET_KEY)

45 while True:

46 data = self._queue.get(True)

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

6 package com.documentum.devprog.eclipse.common;

7

8 import javax.crypto.Cipher;

9 import javax.crypto.spec.SecretKeySpec;

10

11 /**

12 *

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

14 * implementation

15 *

17 * @author Aashish Patil(patil_aashish@emc.com)

18 */

19 public class BlowfishJC

20 {

21

BlowfishCBC.java (https://github.com/draxen/MineBackup.git) Java · 87 lines

36

37

38 public class BlowfishCBC implements Cipher {

39 private static final int ivsize = 8;

40 private static final int bsize = 16;

41 private javax.crypto.Cipher cipher;

42 public int getIVSize() {

43 return ivsize;

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

67

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

69 cipher.init(

70 (mode == ENCRYPT_MODE

Blowfish.java (https://bitbucket.org/festevezga/xobotos.git) Java · 69 lines

39 public KeyGen()

40 {

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

42 }

43 }

57 public Mappings()

58 {

59 put("Cipher.BLOWFISH", "org.bouncycastle.jce.provider.symmetric.Blowfish$ECB");

60 // BEGIN android-removed

61 // put("Cipher.1.3.6.1.4.1.3029.1.2", "org.bouncycastle.jce.provider.symmetric.Blowfish$CBC");

62 // END android-removed

63 put("KeyGenerator.BLOWFISH", "org.bouncycastle.jce.provider.symmetric.Blowfish$KeyGen");

64 put("Alg.Alias.KeyGenerator.1.3.6.1.4.1.3029.1.2", "BLOWFISH");

65 put("AlgorithmParameters.BLOWFISH", "org.bouncycastle.jce.provider.symmetric.Blowfish$AlgParams");

66 put("Alg.Alias.AlgorithmParameters.1.3.6.1.4.1.3029.1.2", "BLOWFISH");

Blowfish.java (https://github.com/dstmath/HWFramework.git) Java · 67 lines

49

50 public static class Mappings extends AlgorithmProvider {

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

52

53 public void configure(ConfigurableProvider configurableProvider) {

54 configurableProvider.addAlgorithm("Mac.BLOWFISHCMAC", PREFIX + "$CMAC");

55 configurableProvider.addAlgorithm("Cipher.BLOWFISH", PREFIX + "$ECB");

58 configurableProvider.addAlgorithm("KeyGenerator.BLOWFISH", PREFIX + "$KeyGen");

59 configurableProvider.addAlgorithm("Alg.Alias.KeyGenerator", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, "BLOWFISH");

60 configurableProvider.addAlgorithm("AlgorithmParameters.BLOWFISH", PREFIX + "$AlgParams");

61 configurableProvider.addAlgorithm("Alg.Alias.AlgorithmParameters", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, "BLOWFISH");

62 }

63 }

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

3 from Crypto import Random

29 return s

30

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

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

33

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

4 pkg_resources.require( "pycrypto" )

5

6 from Crypto.Cipher import Blowfish

7 from Crypto.Util.randpool import RandomPool

8 from Crypto.Util import number

36 def __init__( self, **config ):

37 self.id_secret = config['id_secret']

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

39 def encode_id( self, id ):

40 # Convert to string

__init__.py (https://bitbucket.org/cistrome/cistrome-harvard/) Python · 101 lines ✨ Summary

This is a Python class that provides methods for encoding and decoding IDs using Blowfish encryption with a secret key. The class takes an id_secret parameter in its constructor, which is used to initialize the Blowfish cipher. It also has a per_kind_id_secret_base parameter that can be used to specify a different secret key for each kind of ID.

The encode_id() method takes an object ID and a kind as input and returns the encoded ID using the appropriate Blowfish cipher based on the kind. The decode_id() method does the opposite, decoding the encoded ID back to its original value.

The encode_dict_ids() method is used to encode all IDs in a dictionary, identifying them by either an ‘id’ key or a key that ends with ‘_id’. The decode_guid() method decodes a session key using the same Blowfish cipher as the encode_guid() method.

The class also has a get_new_guid() method that generates a new, high entropy 128-bit random number using the get_random_bytes() function from the Crypto module.

7 pkg_resources.require( "pycrypto" )

8

9 from Crypto.Cipher import Blowfish

10 from Crypto.Util.randpool import RandomPool

11 from Crypto.Util import number

40 def __init__( self, **config ):

41 self.id_secret = config['id_secret']

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

43

44 per_kind_id_secret_base = config.get( 'per_kind_id_secret_base', self.id_secret )

98

99 def __missing__( self, key ):

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

101

CipherFactory.java (https://gitlab.com/lobl.pavel/gcc-6.2.0) Java · 129 lines

37

38

39 package gnu.javax.crypto.cipher;

40

41 import gnu.java.security.Registry;

74 if (name.equalsIgnoreCase(ANUBIS_CIPHER))

75 result = new Anubis();

76 else if (name.equalsIgnoreCase(BLOWFISH_CIPHER))

77 result = new Blowfish();

115 HashSet hs = new HashSet();

116 hs.add(ANUBIS_CIPHER);

117 hs.add(BLOWFISH_CIPHER);

118 hs.add(DES_CIPHER);

119 hs.add(KHAZAD_CIPHER);

TestRSACipherWrap.java (https://github.com/ibmruntimes/openj9-openjdk-jdk9.git) Java · 118 lines

40 import java.security.Provider;

41 import java.util.Arrays;

42 import javax.crypto.Cipher;

43 import javax.crypto.KeyGenerator;

44 import javax.crypto.SecretKey;

66 Cipher cipherJce = Cipher.getInstance(rsaAlgo, "SunJCE");

67

68 String algos[] = {"AES", "RC2", "Blowfish"};

69 int keySizes[] = {128, 256};

70

ChangePasswordRunnable.java (https://github.com/PuffOpenSource/Puff-Android.git) Java · 101 lines

8 import java.util.Stack;

9

10 import javax.crypto.Cipher;

11 import javax.crypto.spec.SecretKeySpec;

12

65

66 private byte[] encrypt(String text) throws Exception{

67 SecretKeySpec skeySpec = new SecretKeySpec(newPassword.getBytes("UTF-8"), "Blowfish");

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

73

74 public byte[] decrypt(byte[] rawText) throws Exception {

75 SecretKeySpec skeySpec = new SecretKeySpec(oldPassword.getBytes("UTF-8"), "Blowfish");

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

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

11 *

12 */

13 import javax.crypto.Cipher;

14 import javax.crypto.KeyGenerator;

15 import javax.crypto.SecretKey;

23 public class Eryptogram {

24 private static String Algorithm = "DES";

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

26 static boolean debug = false;

27

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

194 // Pass Phrase.

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

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

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

198

199 // Create encrypter/decrypter class

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

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

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

203

209 // Decrypt the string

210 String desDecrypted = desEncrypter.decrypt(desEncrypted);

211 String blowfishDecrypted = blowfishEncrypter.decrypt(blowfishEncrypted);

212 String desedeDecrypted = desedeEncrypter.decrypt(desedeEncrypted);

213

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

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

2

3 import java.security.InvalidKeyException;

4 import java.security.NoSuchAlgorithmException;

5

6 import javax.crypto.Cipher;

7 import javax.crypto.NoSuchPaddingException;

8 import javax.crypto.spec.SecretKeySpec;

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

15 *

NavicatEncrypt.java (https://github.com/dbeaver/dbeaver.git) Java · 212 lines

22 private byte[] _iv;

23 private SecretKeySpec keySpec;

24 private javax.crypto.Cipher _chiperCrypt;

25 private javax.crypto.Cipher _chiperDecrypt;

39 md.update(NAVICAT_CODE.getBytes("US-ASCII"), 0, NAVICAT_CODE.length());

40 byte[] key = md.digest();

41 keySpec = new SecretKeySpec(key, "Blowfish");

42 } catch (Exception e) {

43 System.out.println(e.getMessage());

50 try {

51 // Must use NoPadding

52 _chiperCrypt = javax.crypto.Cipher.getInstance("Blowfish/ECB/NoPadding");

53 _chiperCrypt.init(javax.crypto.Cipher.ENCRYPT_MODE, keySpec);

62 try {

63 // Must use NoPadding

64 _chiperDecrypt = javax.crypto.Cipher.getInstance("Blowfish/ECB/NoPadding");

65 _chiperDecrypt.init(javax.crypto.Cipher.DECRYPT_MODE, keySpec);

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

4 """

5

6 from Crypto.Cipher import Blowfish

7 from datetime import datetime

8 from django.conf import settings

65 # Must remember to save it after calling!

66 secret_key = settings.SECRET_KEY

67 encryption_object = Blowfish.new(secret_key)

68 # block cipher length must be a multiple of 8

69 padding = ''

92 def _decryptCC(self):

93 secret_key = settings.SECRET_KEY

94 encryption_object = Blowfish.new(secret_key)

95 # strip padding from decrypted credit card number

96 ccnum = encryption_object.decrypt(base64.b64decode(self.encrypted_cc)).rstrip('X')

BlueBerry.java (https://github.com/Synacktiv/stuffz.git) Java · 108 lines

8 import java.io.InputStreamReader;

9 import java.math.BigInteger;

10 import javax.crypto.Cipher;

11 import javax.crypto.spec.SecretKeySpec;

12

13 public class BlueBerry {

14

15 private static final String algo = "Blowfish";

16

17 // jaas is the way

base.py (https://github.com/niwibe/django-logstream.git) Python · 144 lines

11 import copy

12

13 from Crypto.Cipher import Blowfish

14 from Crypto.Hash import SHA

15

29 self.queue = queue

30 self.storage = storage.Storage(interval=self.logrotate_interval)

31 self.cipher = Blowfish.new(settings.SECRET_KEY)

32

33 while True:

CryptUtil.java (https://github.com/hinemos/hinemos.git) Java · 162 lines

17

18 import javax.crypto.BadPaddingException;

19 import javax.crypto.Cipher;

20 import javax.crypto.IllegalBlockSizeException;

21 import javax.crypto.NoSuchPaddingException;

31

32 // 使用する暗号化アルゴリズム

33 private static String algorithm = "BLOWFISH";

34

35 private static String cryptKey = "hinemos";

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

35 import java.security.NoSuchAlgorithmException;

36

37 import javax.crypto.Cipher;

38 import javax.crypto.NoSuchPaddingException;

39 import javax.crypto.spec.IvParameterSpec;

47 * @version $Revision: 1.21 $

48 */

49 public class BlowfishCbc extends SshCipher {

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

51

52 /** */

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

54 Cipher cipher;

55

56 /**

57 * Creates a new BlowfishCbc object.

58 */

59 public BlowfishCbc() {

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

1 import javax.crypto.Cipher;

2 import java.security.Key;

3 import java.security.KeyStore;

16 import java.io.*;

17

18 public class BlowfishKey {

19

20 public static void main(String[] args) throws Exception {

33

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

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

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

37 return cipher.doFinal(plainText.getBytes());

47

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

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

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

51 byte[] decrypted = cipher.doFinal(cipherText);

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

40 Module name Description

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.

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

8

9 try:

10 from Crypto.Cipher import Blowfish

11 except ImportError:

12 raise ImportError('Using an encrypted field requires the pycripto. You can install pycripto with "pip install pycrypto"')

17

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

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

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

21

pycryptodome-3.10.1-parallel-make.patch (https://github.com/Whissi/gentoo-overlay.git) Patch · 22 lines

3 +++ b/setup.py 2021-02-09 13:46:51.116065599 +0100

4 @@ -360,7 +360,7 @@ ext_modules = [

5 Extension("Crypto.Cipher._raw_eksblowfish",

6 include_dirs=['src/'],

7 define_macros=[('EKS',None),],

8 - sources=["src/blowfish.c"],

9 + sources=["src/blowfish_eks.c"],

10 py_limited_api=True),

11 Extension("Crypto.Cipher._raw_cast",

12 include_dirs=['src/'],

13 @@ -442,7 +442,8 @@ ext_modules = [

EncryptionUtils.java (https://github.com/sbasinge/golfplus.git) Java · 236 lines

6 import java.util.StringTokenizer;

7

8 import javax.crypto.Cipher;

9 import javax.crypto.KeyGenerator;

10 import javax.crypto.SecretKey;

185 }

186

187 // private static String generateBlowfishKey() {

188 // try {

189 // KeyGenerator kgen = KeyGenerator.getInstance("Blowfish");

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

3 import sys

4 import os

5 from Crypto.Cipher import Blowfish #for password storage

6 from hashlib import sha1

7 from random import randrange

51 def set_password(self, key, password):

52 cryptkey = sha1(key).hexdigest()

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

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

55 del password

58 def get_password(self, key):

59 cryptkey = sha1(key).hexdigest()

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

61 try:

62 encrypted_pass = b64dec(self[cryptkey])

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

1 # -*- coding: utf-8 -*-

2 import binascii

3 from Crypto.Cipher import Blowfish

4

5 from django.conf import settings

143 if not self.encrypted_password:

144 return u""

145 enc_obj = Blowfish.new(settings.SECRET_KEY)

146 hex_password = binascii.a2b_hex(self.encrypted_password)

147 return u"%s" % enc_obj.decrypt(hex_password).rstrip()

151 self.encrypted_password = u""

152 else:

153 enc_obj = Blowfish.new(settings.SECRET_KEY)

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

155 value = value + " " * repeat

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

2

3 import org.bouncycastle.crypto.BlockCipher;

4 import org.bouncycastle.crypto.CipherParameters;

5 import org.bouncycastle.crypto.DataLengthException;

6 import org.bouncycastle.crypto.InvalidCipherTextException;

8 import org.bouncycastle.crypto.engines.AESFastEngine;

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

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

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

12 import org.bouncycastle.crypto.engines.CAST6Engine;

61 // 64 bit block ciphers

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]));

65 testReset("DESedeEngine", new DESedeEngine(), new DESedeEngine(), new KeyParameter(new byte[24]));

Blowfish.java (https://github.com/dstmath/HWFramework.git) Java · 53 lines

15 public static class AlgParams extends IvAlgorithmParameters {

16 protected String engineToString() {

17 return "Blowfish IV";

18 }

19 }

33 public static class KeyGen extends BaseKeyGenerator {

34 public KeyGen() {

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

36 }

37 }

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

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

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

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

48 }

49 }

BlowFishCrypt.java (https://bitbucket.org/chatcharin/ofbiz.git) Java · 172 lines

35 *

36 */

37 public class BlowFishCrypt {

38

39 private SecretKeySpec secretKeySpec = null;

51 * @param key An encoded secret key

52 */

53 public BlowFishCrypt(byte[] key) {

54 try {

55 secretKeySpec = new SecretKeySpec(key, "Blowfish");

142 public static boolean testKey(byte[] key) {

143 String testString = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstufwxyz";

144 BlowFishCrypt c = new BlowFishCrypt(key);

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

146 String encryptedMessage = new String(encryptedBytes);

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

12

13 pkg_resources.require( "pycrypto" )

14 from Crypto.Cipher import Blowfish

15 from Crypto.Util.randpool import RandomPool

16 from Crypto.Util import number

18 def encode_id( config_id_secret, obj_id ):

19 # Utility method to encode ID's

20 id_cipher = Blowfish.new( config_id_secret )

21 # Convert to string

22 s = str( obj_id )

telnetenable.py (https://github.com/semyazza/netgear-telenetenable.git) Python · 115 lines

23 import array

24 from optparse import OptionParser

25 from Crypto.Cipher import Blowfish

26 from Crypto.Hash import MD5

27

28 TELNET_PORT = 23

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

32 # little-endian stuff it's getting on intel to Big-Endian

33 #

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

35 # to byteswap our buffer before and after encrypting it

36 #

BlockCipherFactory.java (git://pkgs.fedoraproject.org/ganymed-ssh2) Java · 116 lines

1

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

3

4 import java.util.Vector;

34 /* Higher Priority First */

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"));

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

46 ciphers.addElement(new CipherEntry("3des-ctr", 8, 24, "ch.ethz.ssh2.crypto.cipher.DESede"));

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

5 import java.security.spec.RSAKeyGenParameterSpec;

6

7 import javax.crypto.Cipher;

8 import javax.crypto.KeyGenerator;

9 import javax.crypto.SecretKey;

14

15 /**

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

17 *

18 * @author -Nemesiss-

45 log.info("Initializing Key Generator...");

46

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

48

49 KeyPairGenerator rsaKeyPairGenerator = KeyPairGenerator.getInstance("RSA");

CrytographicTool.java (https://github.com/madsonsilva/caseconductor-platform.git) Java · 125 lines

23 import java.security.Key;

24

25 import javax.crypto.Cipher;

26 import javax.crypto.spec.SecretKeySpec;

27

34 public enum CryptoAlgorithm

35 {

36 DES, BLOWFISH;

37 }

38

50 * @throws Exception

51 */

52 public static String encrypt(final String source, final CryptoAlgorithm algorithm, final String blowfishKey) throws Exception

53 {

54

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

60 protected String engineToString()

61 {

62 return "Blowfish IV";

63 }

64 }

67 extends AlgorithmProvider

68 {

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

70

71 public Mappings()

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

86 }

Crypto.java (https://bitbucket.org/gustavopuga/foundation.git) Java · 124 lines

3 import java.security.NoSuchAlgorithmException;

4

5 import javax.crypto.Cipher;

6 import javax.crypto.KeyGenerator;

7 import javax.crypto.SecretKey;

17 public static final String ALGORITHM_AES = "AES";

18

19 public static final String ALGORITHM_BLOWFISH = "Blowfish";

20

21 public static final String ALGORITHM_DES = "DES";

ciphers.py (https://github.com/PyCQA/bandit.git) Python · 76 lines

2 from Crypto.Cipher import ARC4 as pycrypto_arc4

3 from Crypto.Cipher import Blowfish as pycrypto_blowfish

4 from Crypto.Cipher import DES as pycrypto_des

6 from Cryptodome.Cipher import ARC2 as pycryptodomex_arc2

7 from Cryptodome.Cipher import ARC4 as pycryptodomex_arc4

8 from Cryptodome.Cipher import Blowfish as pycryptodomex_blowfish

9 from Cryptodome.Cipher import DES as pycryptodomex_des

10 from Cryptodome.Cipher import XOR as pycryptodomex_xor

41 bs = pycrypto_blowfish.block_size

42 cipher = pycrypto_blowfish.new(key, pycrypto_blowfish.MODE_CBC, iv)

43 msg = iv + cipher.encrypt(plaintext + padding)

44 bs = pycryptodomex_blowfish.block_size

45 cipher = pycryptodomex_blowfish.new(key, pycryptodomex_blowfish.MODE_CBC, iv)

46 msg = iv + cipher.encrypt(plaintext + padding)

47

BlowFish.java (https://github.com/sakaiproject/sakai.git) Java · 130 lines

19 package org.sakaiproject.basiclti.util;

20

21 import javax.crypto.Cipher;

22 import javax.crypto.SecretKey;

23 import javax.crypto.spec.SecretKeySpec;

26

27 /**

28 * Support Blowfish Encryption and Decryption

29 */

30 public class BlowFish {

48 public static String strengthenKey(String secret, String salt )

49 {

50 if ( secret.length() > BlowFish.MAX_KEY_LENGTH ) return secret;

51

52 // Extend the secret to the maximum Blowfish length

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

33 import javax.crypto.spec.*;

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;}

40 public int getBlockSize(){return bsize;}

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

19 import java.util.logging.Logger;

20

21 import javax.crypto.Cipher;

22

23 import com.l2jserver.Config;

32 *

33 */

34 public class BlowFishKey extends BaseRecievePacket

35 {

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

38 * @param decrypt

39 */

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

41 {

42 super(decrypt);

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

9 Here a simple example on how to encrypt using ECB, with the AES256 cipher:

10

11 import Crypto.Cipher.Types

12 import Crypto.Cipher

22 where ctx = initAES256 key

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

31

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

33 where ctx = initBlowfish key

34

35

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

30 -- | 256 bit keyed blowfish state

31 newtype Blowfish256 = Blowfish256 Context

32

33 -- | 448 bit keyed blowfish state

37 cipherName _ = "blowfish"

38 cipherKeySize _ = KeySizeRange 6 56

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

40

41 instance BlockCipher Blowfish where

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

SecurityUtility.java (https://github.com/HongZhaoHua/jstarcraft-core.git) Java · 427 lines

12 import java.util.Arrays;

13

14 import javax.crypto.Cipher;

15 import javax.crypto.KeyGenerator;

16 import javax.crypto.SecretKey;

35 private static final String AES = "AES";

36

37 private static final String Blowfish = "Blowfish";

38

39 private static final String DES = "DES";

169

170 /**

171 * Blowfish加密

172 *

173 * @param data

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

33 '''

34

35 from Crypto.Cipher import Blowfish

36 from elixir.statements import Statement

37 from sqlalchemy.orm import MapperExtension, EXT_CONTINUE, EXT_STOP

52

53 def encrypt_value(value, secret):

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

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

56

57 def decrypt_value(value, secret):

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

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

60

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

21 import java.util.logging.Logger;

22

23 import javax.crypto.Cipher;

24

25 import com.l2jserver.util.network.BaseSendablePacket;

29 *

30 */

31 public class BlowFishKey extends BaseSendablePacket

32 {

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

36 * @param publicKey

37 */

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

39 {

40 writeC(0x00);

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

4 import java.security.SecureRandom;

5

6 import javax.crypto.Cipher;

7 import javax.crypto.KeyGenerator;

8 import javax.crypto.SecretKey;

14 *

15 * <pre>

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

17 * DES key size must be equal to 56

18 * DESede(TripleDES) key size must be equal to 112 or 168

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

22 * RC4(ARCFOUR) key size must be between 40 and 1024 bits

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

3 import base64

4

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

6 from Crypto.Random import get_random_bytes

7

26 "aes": {"key_sizes": (16, 24, 32), "class": AES},

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

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

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

30 "des": {"key_sizes": (8,), "class": DES},

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

31 standard and has undergone a fair bit of examination.

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.

42 """

43

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

18 import java.security.interfaces.RSAPrivateKey;

19

20 import javax.crypto.Cipher;

21

22 /**

23 * @author -Wooden-

24 */

25 public final class BlowFishKey extends GameToLoginPacket

26 {

27 private byte[] _key;

28

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

30 {

31 super(decrypt);

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

8 import urllib2

9

10 from Crypto.Cipher import Blowfish

11

12 log = logging.getLogger( __name__ )

184 utility method to encode ID's

185 """

186 id_cipher = Blowfish.new( config_id_secret )

187 # Convert to string

188 s = str( obj_id )

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

31 standard and has undergone a fair bit of examination.

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.

48 import IronPyCrypto_Cipher_ARC2 as ARC2

49 import IronPyCrypto_Cipher_ARC4 as ARC4

50 import IronPyCrypto_Cipher_Blowfish as Blowfish

51 import IronPyCrypto_Cipher_CAST as CAST

52 import IronPyCrypto_Cipher_DES as DES

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

5 from time import time

6 from django.conf import settings

7 from Crypto.Cipher import Blowfish

8 from base64 import b64encode, b64decode

9 from django import newforms as forms

11

12 def get_key():

13 cobj = Blowfish.new(settings.SECRET_KEY)

14 text = unicode(time())

15 text += "".join(["_" for i in xrange(8-len(text)%8)])

28 raise ValidationError(_('Incorrect key.'))

29

30 cobj = Blowfish.new(settings.SECRET_KEY)

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

32 try:

AES.java (https://github.com/bage2014/study.git) Java · 76 lines

5 import java.util.Base64;

6

7 import javax.crypto.Cipher;

8 import javax.crypto.KeyGenerator;

9 import javax.crypto.SecretKey;

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.

7 class Encryption(object):

8 def __init__(self):

9 self.__blowfish = None

10

11 @property

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())

16 if not nics:

19 nics.sort()

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

21 self.__blowfish = Blowfish.new(mac)

22

23 return self.__blowfish

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

25 import java.security.KeyPairGenerator;

26 import java.security.spec.RSAKeyGenParameterSpec;

27 import javax.crypto.Cipher;

28 import javax.crypto.KeyGenerator;

29 import javax.crypto.SecretKey;

32

33 /**

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

35 */

36 public class KeyGen

60 log.info("Initializing Key Generator...");

61

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

63

64 KeyPairGenerator rsaKeyPairGenerator = KeyPairGenerator.getInstance("RSA");

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

59 skey = getRawKey(knumb);

60 skeyString = new String(skey);

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

62 }

63 catch (Exception e)

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

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

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

95 byte[] decrypted = cipher.doFinal(encrypted);

99 public static void main(String args[])

100 {

101 BlowFishAlgorithm bf = new BlowFishAlgorithm();

102 }

103 }

107 //import sun.misc.BASE64Decoder;

108 //import sun.misc.BASE64Encoder;

109 //public class BlowFishAlgorithm {

110 //

111 // public static void main(String[] args) throws Exception {

Blowfish.java (https://github.com/dstmath/HWFramework.git) Java · 68 lines

49

50 public static class Mappings extends AlgorithmProvider {

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

52

53 @Override // org.bouncycastle.jcajce.provider.util.AlgorithmProvider

54 public void configure(ConfigurableProvider configurableProvider) {

55 configurableProvider.addAlgorithm("Mac.BLOWFISHCMAC", PREFIX + "$CMAC");

56 configurableProvider.addAlgorithm("Cipher.BLOWFISH", PREFIX + "$ECB");

59 configurableProvider.addAlgorithm("KeyGenerator.BLOWFISH", PREFIX + "$KeyGen");

60 configurableProvider.addAlgorithm("Alg.Alias.KeyGenerator", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, "BLOWFISH");

61 configurableProvider.addAlgorithm("AlgorithmParameters.BLOWFISH", PREFIX + "$AlgParams");

62 configurableProvider.addAlgorithm("Alg.Alias.AlgorithmParameters", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, "BLOWFISH");

63 }

64 }

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

31 import gnu.javax.crypto.assembly.Transformer;

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

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

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

64 TestOfAssembly testcase = new TestOfAssembly();

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),

76

77 testcase.asm = new Assembly();

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

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

80

Blowfish.java (https://github.com/senecaso/spongycastle.git) Java · 67 lines

39 public KeyGen()

40 {

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

42 }

43 }

57 public Mappings()

58 {

59 put("Cipher.BLOWFISH", "org.spongycastle.jce.provider.symmetric.Blowfish$ECB");

60 put("Cipher.1.3.6.1.4.1.3029.1.2", "org.spongycastle.jce.provider.symmetric.Blowfish$CBC");

61 put("KeyGenerator.BLOWFISH", "org.spongycastle.jce.provider.symmetric.Blowfish$KeyGen");

62 put("Alg.Alias.KeyGenerator.1.3.6.1.4.1.3029.1.2", "BLOWFISH");

63 put("AlgorithmParameters.BLOWFISH", "org.spongycastle.jce.provider.symmetric.Blowfish$AlgParams");

64 put("Alg.Alias.AlgorithmParameters.1.3.6.1.4.1.3029.1.2", "BLOWFISH");

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

20 import java.security.spec.RSAKeyGenParameterSpec;

21

22 import javax.crypto.Cipher;

23 import javax.crypto.KeyGenerator;

24 import javax.crypto.SecretKey;

28

29 /**

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

31 */

32

57 log.info("Iniciando el generador de claves de acceso..");

58

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

60

61 KeyPairGenerator rsaKeyPairGenerator = KeyPairGenerator.getInstance("RSA");

__init__.py (https://gitlab.com/gregtyka/server) Python · 33 lines

11 standard and has undergone a fair bit of examination.

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.

24 """

25

Blowfish.java (https://github.com/dstmath/HWFramework.git) Java · 82 lines

22 public static class CBC extends BaseBlockCipher {

23 public CBC() {

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

25 }

26 }

66 // Can't load method instructions.

67 */

68 throw new UnsupportedOperationException("Method not decompiled: com.android.org.bouncycastle.jcajce.provider.symmetric.Blowfish.Mappings.<clinit>():void");

69 }

70

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

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

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

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

77 }

78 }

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

7 Author: Vincent Hanquez <vincent@snarc.org>

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

9 Synopsis: Blowfish cipher

10 Category: Cryptography

11 Build-Type: Simple

20 , securemem >= 0.1.2

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

22 Exposed-modules: Crypto.Cipher.Blowfish

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

24 ghc-options: -Wall -optc-O3 -fno-cse -fwarn-tabs

25

26 Test-Suite test-cipher-blowfish

27 type: exitcode-stdio-1.0

28 hs-source-dirs: Tests

PEMUtilities.java (https://github.com/BiglySoftware/BiglyBT.git) Java · 186 lines

5 import java.security.spec.AlgorithmParameterSpec;

6

7 import javax.crypto.Cipher;

8 import javax.crypto.SecretKey;

9 import javax.crypto.spec.IvParameterSpec;

70 else if (dekAlgName.startsWith("BF-"))

71 {

72 alg = "Blowfish";

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

74 }

BlowfishEncryptionAlgorithm.java (https://github.com/superblaubeere27/obfuscator.git) Java · 50 lines

11 package me.superblaubeere27.jobf.processors.encryption.string;

12

13 import javax.crypto.Cipher;

14 import javax.crypto.spec.SecretKeySpec;

15 import java.nio.charset.StandardCharsets;

17 import java.util.Base64;

18

19 public class BlowfishEncryptionAlgorithm implements IStringEncryptionAlgorithm {

20 public static String decrypt(String obj, String key) {

21 try {

22 SecretKeySpec keySpec = new SecretKeySpec(MessageDigest.getInstance("MD5").digest(key.getBytes(StandardCharsets.UTF_8)), "Blowfish");

23

24 Cipher des = Cipher.getInstance("Blowfish");

CryptoRunnable.java (https://github.com/PuffOpenSource/Puff-Android.git) Java · 91 lines

3 import android.util.Base64;

4

5 import javax.crypto.Cipher;

6 import javax.crypto.spec.SecretKeySpec;

7

75

76 private byte[] encrypt() throws Exception{

77 SecretKeySpec skeySpec = new SecretKeySpec(password.getBytes("UTF-8"), "Blowfish");

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

83

84 public byte[] decrypt() throws Exception {

85 SecretKeySpec skeySpec = new SecretKeySpec(password.getBytes("UTF-8"), "Blowfish");

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

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

17 * under the License.

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,

33 * used in this implementation.

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

37 * Jurisdiction Policy files</a>.

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

19 , cipher-rc4 >= 0.1.3 && < 0.2

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

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

3

4 from Crypto import Util

5 from Crypto.Cipher import AES, Blowfish, DES3

6 from Crypto.PublicKey import RSA, DSA

7 from pyasn1.codec.der import decoder as DERDecoder

Blowfish.java (https://github.com/SivanLiu/HwFrameWorkSource.git) Java · 62 lines

2

3 import com.android.org.bouncycastle.asn1.misc.MiscObjectIdentifiers;

4 import com.android.org.bouncycastle.crypto.CipherKeyGenerator;

5 import com.android.org.bouncycastle.crypto.engines.BlowfishEngine;

15 public static class KeyGen extends BaseKeyGenerator {

16 public KeyGen() {

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

18 }

19 }

32 provider.addAlgorithm("KeyGenerator.BLOWFISH", stringBuilder.toString());

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

34 stringBuilder = new StringBuilder();

35 stringBuilder.append(PREFIX);

37 provider.addAlgorithm("AlgorithmParameters.BLOWFISH", stringBuilder.toString());

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

39 }

40 }

ThreeDesUtil.java (https://github.com/uustory/U8Server.git) Java · 84 lines

3 import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;

4

5 import javax.crypto.Cipher;

6 import javax.crypto.SecretKey;

7 import javax.crypto.spec.SecretKeySpec;

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

24 randompool = None

25 if hasCrypto:

26 from Crypto.Cipher import Blowfish

27 from Crypto.Util.randpool import RandomPool

28 randompool = RandomPool(500)

45 key = privatekeys[config.serverhostname].decrypt(key)

46 s = decodestring(data)

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

48 s = b.decrypt(s)

49 s = decompress(s)

59 if not hasattr(request, '_my_secret'):

60 request._my_secret = genPassword()

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

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

63 return encodestring(res)