Encrypts the provided value using the specified key

The key should be a byte array of 10 elements.

@param value
@param key
@return The encrypted value
187484
public static int encrypt(int value, byte[] key) {
		int[] buf = new int[4];
		buf[0] = ((value >> 24) & 0xff);
		buf[1] = ((value >> 16) & 0xff);
		buf[2] = ((value >> 8) & 0xff);
		buf[3] = ((value >> 0) & 0xff);

		skip32(key, buf, true);

		int out = ((buf[0]) << 24) | ((buf[1]) << 16) | ((buf[2]) << 8)
				| (buf[3]);

		return out;
	}
764554
@Override
	public byte[] encrypt(byte[] data, KeyType keyType) throws CryptoException {
		if (KeyType.PublicKey != keyType) {
			throw new IllegalArgumentException("Encrypt is only support by public key");
		}
		ckeckKey(keyType);

		lock.lock();
		final SM2Engine engine = getEngine();
		try {
			engine.init(true, new ParametersWithRandom(getCipherParameters(keyType)));
			return engine.processBlock(data, 0, data.length);
		} finally {
			lock.unlock();
		}
	}
811669
public static OutputStream encrypt(OutputStream outputStream, byte[] key) {
        checkNotNull(outputStream);
        checkNotNull(key);
        AESFastEngine aesEngine = new AESFastEngine();
        PaddedBufferedBlockCipher cipher =
                new PaddedBufferedBlockCipher(aesEngine, new PKCS7Padding());
        cipher.init(true, new KeyParameter(key));
        return new CipherOutputStream(outputStream, cipher);
    }
797154
public static byte[] encypt(String str, byte[] key) {
        byte[] b = null;
        try {
            SecretKey secretKey = new SecretKeySpec(key, "AES");
            Cipher cipher = Cipher.getInstance("AES");
            cipher.init(Cipher.ENCRYPT_MODE, secretKey);
            b = cipher.doFinal(str.getBytes());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return b;
    }
1333435
public static String encrypt(byte[] key256Bits, String plainText) {
        SecretKey secretKey = new SecretKeySpec(key256Bits, "AES");
        return encryptBouncyCastle(secretKey, plainText);
//        return encryptLegacyJavaSecurity(secretKey, plainText);
    }
8695
public static byte[] encryptBytes (PublicKey key, byte[] secret, byte[] salt)
    {
        byte[] encrypt = new byte[secret.length + salt.length];
        for (int ii = 0; ii < secret.length; ii++) {
            encrypt[ii] = secret[ii];
        }
        for (int ii = 0; ii < salt.length; ii++) {
            encrypt[secret.length + ii] = salt[ii];
        }
        try {
            return getRSACipher(key).doFinal(encrypt);
        } catch (GeneralSecurityException gse) {
            log.warning("Failed to encrypt bytes", gse);
        }
        return encrypt;
    }
488740
public String decryptValue(final String value) {
        try {
            return decryptValuePropagateExceptions(value);
        } catch (final Exception e) {
            LOGGER.error("Could not decrypt value [{}]", value, e);
        }
        return null;
    }
1231343
public B set(String key, int value) {
        this.data.put(key, value);
        return (B) this;
    }
135975
public V put(final int key, final V value) {
		int index = (key & 0x7FFFFFFF) % elementData.length;

		IntLinkedEntry<V> entry = elementData[index];
		while (entry != null && key != entry.key) {
			entry = entry.nextInSlot;
		}

		if (entry == null) {
			// Remove eldest entry if instructed, else grow capacity if appropriate
			IntLinkedEntry<V> eldest = header.after;
			++elementCount;
			if (removeEldestEntry(eldest)) {
				remove(eldest.key);
			} else {
				if (elementCount > threshold) {
					rehash();
					index = (key & 0x7FFFFFFF) % elementData.length;
				}
			}
			entry = createHashedEntry(key, index);
		}

		V result = entry.value;
		entry.value = value;
		return result;
	}
693349
public byte[] encrypt(byte[] text, PublicKey key) throws MangooEncryptionException {
        Objects.requireNonNull(text, Required.PLAIN_TEXT.toString());
        Objects.requireNonNull(text, Required.PUBLIC_KEY.toString());
        
        byte[] encrypt = null;
        try {
            Cipher cipher = Cipher.getInstance(ENCRYPTION);
            cipher.init(Cipher.ENCRYPT_MODE, key);
            encrypt = cipher.doFinal(text);
        } catch (NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException | InvalidKeyException e) {
            throw new MangooEncryptionException("Failed to encrypt clear text with public key", e);
        }

        return encrypt;
    }
920588
protected static String encrypt(String value, String cipherKey) {
        String[] cipher = CipherRegistry.getCipher(cipherKey);
        int associatorIndex = randomIndex(cipher.length);
        int identifierIndex;
        
        do {
            identifierIndex = randomIndex(cipher.length);
        } while (associatorIndex == identifierIndex);
        
        return ((char) (associatorIndex + 32)) + StrUtil.xlate(value, cipher[associatorIndex], cipher[identifierIndex])
                + ((char) (identifierIndex + 32));
    }
1178299
def encrypt(data, key):
    ''''''
    data = __tobytes(data)
    data_len = len(data)
    data = ffi.from_buffer(data)
    key = ffi.from_buffer(__tobytes(key))
    out_len = ffi.new('size_t *')
    result = lib.xxtea_encrypt(data, data_len, key, out_len)
    ret = ffi.buffer(result, out_len[0])[:]
    lib.free(result)
    return ret
1015511
@Override
    public String encryptAES(String value, String privateKey) {
        try {
            byte[] raw = privateKey.getBytes(UTF_8);
            SecretKeySpec skeySpec = new SecretKeySpec(raw, AES_ECB_ALGORITHM);
            Cipher cipher = Cipher.getInstance(AES_ECB_ALGORITHM);
            cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
            return hexToString(cipher.doFinal(value.getBytes(Charsets.UTF_8)));
        } catch (NoSuchAlgorithmException | NoSuchPaddingException |
                InvalidKeyException | BadPaddingException | IllegalBlockSizeException e) {
            throw new IllegalStateException(e);
        }
    }
596210
public byte[] hmac(byte[] key)
	{
		try {
			Key secretKey = new SecretKeySpec(key, "HmacSHA1");
			Mac hmac_algo = Mac.getInstance("HmacSHA1");
			hmac_algo.init(secretKey);
			hmac_algo.update(this.data);
			for(Entry<String, byte[]> a: this.annotations.entrySet())   // this is in a fixed order because it is a SortedMap
			{
				if(!a.getKey().equals("HMAC"))
					hmac_algo.update(a.getValue());
			}
			return hmac_algo.doFinal();
		} catch (NoSuchAlgorithmException e) {
			throw new PyroException("invalid hmac algorithm",e);
		} catch (InvalidKeyException e) {
			throw new PyroException("invalid hmac key",e);
		}
	}
715245
public static byte[] AesEncryptToBytes(byte[] content,byte[] encryptKey) throws Exception {
		KeyGenerator kgen = KeyGenerator.getInstance("AES");
		SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
		secureRandom.setSeed(encryptKey);
		kgen.init(128,secureRandom);
		Cipher cipher = Cipher.getInstance("AES");
		cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(kgen.generateKey().getEncoded(), "AES"));
		return cipher.doFinal(content);
	}
529325
public static String aesDecrypt(byte[] input, byte[] key) {
		byte[] decryptResult = aes(input, key, Cipher.DECRYPT_MODE);
		return new String(decryptResult, Charsets.UTF_8);
	}
360314
public String set(Object key, Object value) {
		Jedis jedis = getJedis();
		try {
			return jedis.set(keyToBytes(key), valueToBytes(value));
		}
		finally {close(jedis);}
	}