反序列化时JVM如何找到对象类的serialVersionUID

时间:2019-01-23 07:54:17

标签: java

假设我有一个实现Serializable接口的实体类,现在我将该序列化的对象保留在数据库中。 JVM在反序列化时如何找到对象类的serialVersionUID。

1 个答案:

答案 0 :(得分:0)

序列化对象时,它是类名和openssl_encrypt存储在流中。

当对象按名称反序列化JVM加载类时,将已加载类的<?php $key = 'bRuD5WYw5wd0rdHR9yLlM6wt2vteuiniQBqE70nAuhU='; function my_encrypt($data, $key) { $encryption_key = base64_decode($key); $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc')); $encrypted = openssl_encrypt($data, 'aes-256-cbc', $encryption_key, 0, $iv); return base64_encode($encrypted . '::' . $iv); } function my_decrypt($data, $key) { $encryption_key = base64_decode($key); list($encrypted_data, $iv) = explode('::', base64_decode($data), 2); return openssl_decrypt($encrypted_data, 'aes-256-cbc', $encryption_key, 0, $iv); } $password_plain = 'abc123'; echo $password_plain . "<br>"; $password_encrypted = my_encrypt($password_plain, $key); echo $password_encrypted . "<br>"; $password_decrypted = my_decrypt($password_encrypted, $key); echo $password_decrypted . "<br>"; 与存储值进行比较。