open db code:
dbname := `***.db`
key := "dd85344"
dbnameWithDSN := dbname + fmt.Sprintf("?_pragma_key=x'%s'&_pragma_cipher_page_size=4096", key)
db, err := gorm.Open(sqlite.Open(dbnameWithDSN), &gorm.Config{})
or:
dbname := `***.db`
key := "dd85344"
dbnameWithDSN := dbname + fmt.Sprintf("?_pragma_key=x'%s'&_pragma_cipher_page_size=4096", key)
db, _ := sql.Open("sqlite3", dbname)
The password is definitely correct, but my key is 7 bits and the official word is that it must be 32 bytes hexadecimal code.
I think the problem is here, but I don't know how to convert it next...
db, err := sql.Open("sqlite3", `xxx.db?_pragma_key=x'dd85344'&_pragma_cipher_page_size=1024`)
if err != nil {
t.Fatal(err)
}
rows, err := db.Query("SELECT id,value FROM userinfo")
if err != nil {
t.Fatal(err)
}
return err: file is not a database
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.