MySQL column encryption with Hibernate in Spring MVC
up vote
0
down vote
favorite
I need to encrypt data saved onto my DB. I am currently using spring and hibernate to save data.
I have looked at some materials and tried to implement the code, however, it has resulted in various generic errors, some of the material was not targeted to MySQL etc.
Here's the code that has got me furthest
@Column(name="disability_description")
@Length(max=500)
@ColumnTransformer(
read = "AES_DECRYPT(disability_description, 'mykey')",
write = "AES_ENCRYPT(?, 'mykey')"
)
private String disabilityDescription;
This, however, doesn't work as I get the following errors
org.hibernate.exception.GenericJDBCException: could not execute statement
java.sql.SQLException: Incorrect string value: 'xF9x82ux01x99x1A...' for column 'disability_description' at row 1
Please point in the right direction. I am lost. Also mykey
doesn't point to anything, I just entered a random word.
spring hibernate spring-mvc
add a comment |
up vote
0
down vote
favorite
I need to encrypt data saved onto my DB. I am currently using spring and hibernate to save data.
I have looked at some materials and tried to implement the code, however, it has resulted in various generic errors, some of the material was not targeted to MySQL etc.
Here's the code that has got me furthest
@Column(name="disability_description")
@Length(max=500)
@ColumnTransformer(
read = "AES_DECRYPT(disability_description, 'mykey')",
write = "AES_ENCRYPT(?, 'mykey')"
)
private String disabilityDescription;
This, however, doesn't work as I get the following errors
org.hibernate.exception.GenericJDBCException: could not execute statement
java.sql.SQLException: Incorrect string value: 'xF9x82ux01x99x1A...' for column 'disability_description' at row 1
Please point in the right direction. I am lost. Also mykey
doesn't point to anything, I just entered a random word.
spring hibernate spring-mvc
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I need to encrypt data saved onto my DB. I am currently using spring and hibernate to save data.
I have looked at some materials and tried to implement the code, however, it has resulted in various generic errors, some of the material was not targeted to MySQL etc.
Here's the code that has got me furthest
@Column(name="disability_description")
@Length(max=500)
@ColumnTransformer(
read = "AES_DECRYPT(disability_description, 'mykey')",
write = "AES_ENCRYPT(?, 'mykey')"
)
private String disabilityDescription;
This, however, doesn't work as I get the following errors
org.hibernate.exception.GenericJDBCException: could not execute statement
java.sql.SQLException: Incorrect string value: 'xF9x82ux01x99x1A...' for column 'disability_description' at row 1
Please point in the right direction. I am lost. Also mykey
doesn't point to anything, I just entered a random word.
spring hibernate spring-mvc
I need to encrypt data saved onto my DB. I am currently using spring and hibernate to save data.
I have looked at some materials and tried to implement the code, however, it has resulted in various generic errors, some of the material was not targeted to MySQL etc.
Here's the code that has got me furthest
@Column(name="disability_description")
@Length(max=500)
@ColumnTransformer(
read = "AES_DECRYPT(disability_description, 'mykey')",
write = "AES_ENCRYPT(?, 'mykey')"
)
private String disabilityDescription;
This, however, doesn't work as I get the following errors
org.hibernate.exception.GenericJDBCException: could not execute statement
java.sql.SQLException: Incorrect string value: 'xF9x82ux01x99x1A...' for column 'disability_description' at row 1
Please point in the right direction. I am lost. Also mykey
doesn't point to anything, I just entered a random word.
spring hibernate spring-mvc
spring hibernate spring-mvc
asked Nov 22 at 15:44
Yanis K
438
438
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
I doubt that your column is not of type BINARY:
Mysql Doc:
AES_ENCRYPT() encrypts the string str using the key string key_str and
returns a binary string containing the encrypted output.
Yes, you are absolutely correct. Thank you for your time you got this spot on, I changed it to VARBINARY and voila! Happens all the time, spend all this time doing something and then it is so simple and right in front of you. Thanks again
– Yanis K
Nov 22 at 16:05
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I doubt that your column is not of type BINARY:
Mysql Doc:
AES_ENCRYPT() encrypts the string str using the key string key_str and
returns a binary string containing the encrypted output.
Yes, you are absolutely correct. Thank you for your time you got this spot on, I changed it to VARBINARY and voila! Happens all the time, spend all this time doing something and then it is so simple and right in front of you. Thanks again
– Yanis K
Nov 22 at 16:05
add a comment |
up vote
0
down vote
accepted
I doubt that your column is not of type BINARY:
Mysql Doc:
AES_ENCRYPT() encrypts the string str using the key string key_str and
returns a binary string containing the encrypted output.
Yes, you are absolutely correct. Thank you for your time you got this spot on, I changed it to VARBINARY and voila! Happens all the time, spend all this time doing something and then it is so simple and right in front of you. Thanks again
– Yanis K
Nov 22 at 16:05
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I doubt that your column is not of type BINARY:
Mysql Doc:
AES_ENCRYPT() encrypts the string str using the key string key_str and
returns a binary string containing the encrypted output.
I doubt that your column is not of type BINARY:
Mysql Doc:
AES_ENCRYPT() encrypts the string str using the key string key_str and
returns a binary string containing the encrypted output.
answered Nov 22 at 15:58
hasnae
1,2551016
1,2551016
Yes, you are absolutely correct. Thank you for your time you got this spot on, I changed it to VARBINARY and voila! Happens all the time, spend all this time doing something and then it is so simple and right in front of you. Thanks again
– Yanis K
Nov 22 at 16:05
add a comment |
Yes, you are absolutely correct. Thank you for your time you got this spot on, I changed it to VARBINARY and voila! Happens all the time, spend all this time doing something and then it is so simple and right in front of you. Thanks again
– Yanis K
Nov 22 at 16:05
Yes, you are absolutely correct. Thank you for your time you got this spot on, I changed it to VARBINARY and voila! Happens all the time, spend all this time doing something and then it is so simple and right in front of you. Thanks again
– Yanis K
Nov 22 at 16:05
Yes, you are absolutely correct. Thank you for your time you got this spot on, I changed it to VARBINARY and voila! Happens all the time, spend all this time doing something and then it is so simple and right in front of you. Thanks again
– Yanis K
Nov 22 at 16:05
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434384%2fmysql-column-encryption-with-hibernate-in-spring-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown