简体   繁体   中英

Storing a .pem file in MySql

I have a form and I need to upload a .pem file through a restful webservice. I see that in my requisition the field for the file is actually the hash of the certificate. I can save all other informations in the db of the webservice, but the field for the file is always "null".

What is the appropriate type for storing this hash? I already tried Blob and LongText, Varchar, etc

tnx in advance

PEM format is text ( base 64 encoding with ------BEGIN CERTIFICATE----- and -----END CERTIFICATE----- headers). You would need a long VARCHAR to store it. A hash is binary format so you need a BLOB

But a hash has a small size. For example 20 bytes for SHA1 and 32 bytes for SHA256. Depending on your storage you can use a fixed length VARCHAR converting the binary value to HEX ( size x2) or BASE64 (size x 1,33)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM