标签: encryption

试图解密sha256哈希

我需要你的帮助,这是我在PHP中的加密代码,它工作正常,但我不知道如何在PHP中解密它.我需要恢复实际价值.我在c#中有类似的代码,我能够得到相同的结果.但我需要解密这个价值.

<?php 

$DATA= 'james' ;
$KEY= 'moveme'; 

$hash = hash_hmac("sha256", utf8_encode($DATA), utf8_encode($KEY), false); 

echo $hash; 

?>
Run Code Online (Sandbox Code Playgroud)

php encryption

-2
推荐指数
1
解决办法
2万
查看次数

我如何在登录表单中使用sha512?

我投入了 security.yml

Acme\UserBundle\Entity\User: sha512
Run Code Online (Sandbox Code Playgroud)

但我也改变了这个?:

$this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
Run Code Online (Sandbox Code Playgroud)

$this->salt = base_convert(sha512(uniqid(mt_rand(), true)), 16, 36);
Run Code Online (Sandbox Code Playgroud)


如果我有这个security.yml:

Acme\UserBundle\Entity\User: sha512
Run Code Online (Sandbox Code Playgroud)

如果我有这个 user.php

$this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
Run Code Online (Sandbox Code Playgroud)

当我登录返回给我

提供的密码无效.

为什么?

security encryption symfony

-2
推荐指数
1
解决办法
374
查看次数

从w到〜的加密形式的字母存储为?在sql server中

我正在加密密码并将加密的密码存储在数据库中.加密密钥是8.例如,如果我的密码是abc,那么加密形式的abc将ijk存储在数据库中.直到这封信v,这是正常的.ASCII值为v118.所以,118 + 8 = 126即; ~将被存储为v的加密形式.但是,从信件w~ie; 从119到126,这些字母的加密形式存储在数据库中?.有没有更好的方法来加密这8个字母?

c# sql-server encryption

-2
推荐指数
1
解决办法
49
查看次数

php MD5中的密码哈希

有谁能告诉我这有什么不对吗?

function hashmyshit($pass){

        for ( $i = 0; $i < 1000; $i++ ){
            MD5($pass);
        }
        return $pass;
}
Run Code Online (Sandbox Code Playgroud)

以及如何多次迭代密码散列过程.

php encryption hash md5

-2
推荐指数
1
解决办法
567
查看次数

Android 加密大文件

我尝试加密和解密大型音频二进制文件。使用 CipherInputStream 和 CipherOutputStream。我知道,关于像这样的主题存在许多问题。但我不明白我的代码有什么问题。请描述清楚是什么错误。谢谢。

public void encrypt() {
    doCrypto(Cipher.ENCRYPT_MODE, KEY);
}

public void decrypt() {
    doCrypto(Cipher.DECRYPT_MODE, KEY);
}

private void doCrypto(int cipherMode, String key) {
    try {
        Key secretKey = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
        Cipher cipher = Cipher.getInstance("AES");
        cipher.init(cipherMode, secretKey);

        FileInputStream inputStream = new FileInputStream(this);
        FileOutputStream fileOutputStream = new FileOutputStream(this);

        int read;

        CipherInputStream cis = new CipherInputStream(inputStream, cipher);
        CipherOutputStream cos = new CipherOutputStream(fileOutputStream, cipher);

        while ((read = cis.read()) != -1) {
            cos.write(read);
            cos.flush();
        }
        cos.close();
        cis.close();

        inputStream.close();
        fileOutputStream.close();

    } catch (NoSuchPaddingException …
Run Code Online (Sandbox Code Playgroud)

encryption android

-2
推荐指数
1
解决办法
1677
查看次数

如何在java中解密加密的String

我有String s="abc"; 加密字符串显示:ðá£ÅÉûË¿~?‰+×µÚ 和解密相同的值.

但是现在我有相同的加密字符串ðá£ÅÉûË¿~?‰+×µÚ,我可以获得/解密它吗?下面我正在使用的代码.

String key = "Bar12345Bar12345"; // 128 bit key
// Create key and cipher
Key aesKey = new SecretKeySpec(key.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES");
// encrypt the text
cipher.init(Cipher.ENCRYPT_MODE, aesKey);
byte[] encrypted = cipher.doFinal(text.getBytes());
String e=new String(encrypted);
byte[] encrypted1 = cipher.doFinal(e.getBytes());
System.out.println(encrypted.length+" "+encrypted1.length);
System.out.println(e);
// decrypt the text
cipher.init(Cipher.DECRYPT_MODE, aesKey);
String decrypted = new String(cipher.doFinal(encrypted));
System.out.println(decrypted);
Run Code Online (Sandbox Code Playgroud)

java encryption

-2
推荐指数
1
解决办法
9295
查看次数

base64编码与密码的小写转换结合的安全性如何?

我目前正在开展一个学校项目,部分任务是启用用户登录.因此我认为使用简单的base64编码以及之后的小写转换将是一个非常好的加密,因为base64通常由大写和小写字符组成.这是一个代表性代码:

set @passwd = 'Password';
set @salt = 'Salt';
set @email = 'tmp@gmail.com';

INSERT INTO `db_scrumboardtable`.`tb_user` (`mail`, `password`, `nameToDisplay`) VALUES (@email, LOWER(to_base64(sha2(concat(@passwd,@salt),512))) , 'test');

select u.tb_User_id from `db_scrumboardtable`.`tb_user` u where u.mail = @email and u.password = LOWER(to_base64(sha2(concat(@passwd,@salt),512)));
Run Code Online (Sandbox Code Playgroud)

mysql encryption base64

-2
推荐指数
1
解决办法
744
查看次数

javax.crypto.Cipher update(byte [])和doFinal()与doFinal(byte [])

我有一些使用javax.crypto.Cipher的加密代码,当我像这样加密时,可以正常工作:

byte[] data = cipher.doFinal(srcdata); // srcdata is a byte[]
Run Code Online (Sandbox Code Playgroud)

但是我遇到了多个字节[]想要作为一个块加密的情况。所以我尝试了这个:

for (byte[] block : blocks) {
    cipher.update(block);
}

byte[] data = cipher.doFinal();
Run Code Online (Sandbox Code Playgroud)

当我解码该结果时,出现以下错误:

javax.crypto.BadPaddingException: Given final block not properly padded
    at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)
    at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
    at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)
    at javax.crypto.Cipher.doFinal(Cipher.java:2131)
Run Code Online (Sandbox Code Playgroud)

阅读Cipher的Java文档,看来应该可以使用。

我究竟做错了什么?

java encryption aes

-2
推荐指数
1
解决办法
1391
查看次数

双重加密

我正在使用https://github.com/simbiose/Encryption来加密我的 android 应用程序中的数据。

我想到了双重加密。

String key = "key";
String salt = "someSalt";
byte[] iv = new byte[16];
Encryption encryption = Encryption.getDefault(key, salt, iv);

String encrypted = encryption.encryptOrNull("Some String");

Log.d("Encrypto", "Encryption Level 1 : "+encrypted);

encrypted = encryption.encryptOrNull(encrypted);

Log.d("Encrypto", "Encryption Level 2 : "+encrypted);

String decrypted = encryption.decryptOrNull(encrypted);

Log.d("Encrypto", "Decryption Level 2 : "+decrypted);

decrypted = encryption.decryptOrNull(decrypted);

Log.d("Encrypto", "Decryption Level 1 : "+decrypted);
Run Code Online (Sandbox Code Playgroud)

这很有效,但是否推荐?

  1. 是的,这会增加存储加密字符串的内存使用量,但如果它更安全,使用更多内存就可以了。
  2. 如果我这样做,我会遇到一些问题吗?

主要问题:这是一个好的加密库吗?如果没有请推荐我一个更好的

java security encryption

-2
推荐指数
1
解决办法
873
查看次数

如何在 Ruby 中解密由 Node 已弃用的 createCipher 加密的数据?

我有一些遗留数据,在 Node 中加密,我需要在 Ruby 中解密。

问题是,数据是使用现已弃用的方法加密的,createCipher. 此方法使用密码来执行加密。它已被替换为createCipheriv,它需要一个 32 字节的密钥和一个 16 字节的初始化向量。

在 Node 中,我可以使用同样不推荐使用的 解密字符串createDecipher,它也接受密码。但是,我不知道 Ruby 中有任何等效的方法,这是有道理的,因为现在已知这些方法不安全并且已弃用。

Ruby的OpenSSL的AES密码正确,需要一个32字节的密钥和16字节的IV类的较新的createCipheriv,但我没有任何的这些,只有原来的密码,我用createCipher

如何在 Ruby 中获得类似createCipher/createDecipher的行为?

具体来说,鉴于以下 JavaScript ...

const crypto = require('crypto');

const cipher = crypto.createCipher("aes-256-cbc", 'secret password');
cipherText = cipher.update('dummy string', "utf8", "hex") + cipher.final("hex");

console.log(cipherText); // f3051259f83c7ca2ac012a396c4c0848
Run Code Online (Sandbox Code Playgroud)

...如何使用密码'secret password'解密字符串'f3051259f83c7ca2ac012a396c4c0848'并返回'dummy string'Ruby中的输入值?

ruby encryption cryptography node.js

-2
推荐指数
1
解决办法
450
查看次数

标签 统计

encryption ×10

java ×3

php ×2

security ×2

aes ×1

android ×1

base64 ×1

c# ×1

cryptography ×1

hash ×1

md5 ×1

mysql ×1

node.js ×1

ruby ×1

sql-server ×1

symfony ×1