How to open database encrypted with sqlcipher - sqlite.swift

Could anyone post code sample of how to open sqlcipher database? I guess that we need to call the key function in some way.

Assuming you've installed SQLite.swift with SQLCipher support (if not, follow these instructions), you merely need to call the key function on your Database object:
import SQLite
let db = Database("path/to/ciphered.sqlite3")
db.key("your_key")
Once keyed, you can change the encryption key using rekey:
db.rekey("your_new_key")

Take a look at SQLite.swift.
To see how to call the underlying sqlcipher functions. e.g.
sqlite3_key(), see Cipher.swift
To see how to open a sqlcipher database in SQlite.swift with a key:
CipherTests.swift

Related

Do I have to store sentry public key in an .env file

Everything is more or less said in the title. When I start the sentry sdk I have a dsn string that I have to write in my code to initialize it. I was wondering if I can hardcode this string or if I have to store it somewhere else. I wonder if it is dangerous or not. Thanks in advance.
Example of initialization: Sentry.init("https://examplePublicKey#o0.ingest.sentry.io/0")
This is a public address. The DSN string only allows events to be sent to a Sentry project. It doesn't give access to retrieve any data from it nor it can be used to execute any operation on your behalf. If for some reason it gets abused (bogus events start coming in), you can easily discard that DSN and create a new one.

Get ShaXXX of a GO Package

I Need to get the Sha512 or similar from a Golang package for SBOM purposes.
For example, the hash for package
https://pkg.go.dev/encoding/json
I can't found any information or api to get it. If possible I need it without download the source code.
I think you are looking for sum.golang.org which is
an auditable checksum database which will be used by the go command to
authenticate modules.
you can read more on how it works on this post from go blog

react native - validate source using digital signature with JWS, bcrypt or react-native-crypto

I am looking for a way to validate the source of a data in my React Native application.
The application receive data in JSON format and I want to validate its source.
I don't need to encrypt the data itself but I want to process only validated data otherwise I will notify the user the data is not originated from a valid source.
I am using RN version 0.45.1
EDIT
I've read that its not a good idea to use JWS, for example:
https://paragonie.com/blog/2017/03/jwt-json-web-tokens-is-bad-standard-that-everyone-should-avoid
but instead use 'react-native-bcrypt' or 'react-native-crypto', the second package is faster??
After a lot of searching I found this solution:
https://github.com/kjur/jsrsasign
this library provides ways to:
generate:
https://kjur.github.io/jsrsasign/api/symbols/KEYUTIL.html#.generateKeypair
sign and verify:https://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.Signature.html#constructor:
and many more...

How can I generate TempURL for object on Object Storage of SoftLayer

How can I generate TempURL for object on Object Storage of SoftLayer?
I currently use Ruby API and I can access my object after authenticate.
But for external End Users, I need to generate public URL for that object which is can be accessed without authentication process.
I tried to generate Temp URL with expiration, but I cannot find key for hexdigest() of HMAC. How can I found it? or is there any other way to get same result?
I can do it using the swift client like this:
We add the temporary urls secret keys with the command:
$ swift post -m "Temp-URL-Key:mykey"
We create the temporary URL:
$ swift-temp-url GET 3600 /v1/AUTH_d684780d-aafe-4772-bcbb-0f07d5f6edf3/a-container/data.txt mykey
it returns:
v1/AUTH_d684780d-aafe-4772-bcbb-0f07d5f6edf3/a-container/data.txt?temp_url_sig=19f067d38dc532883e8f02be3b43a172c61e51d2&temp_url_expires=1445615769
Then we can access to the file:
curl 'https://dal05.objectstorage.softlayer.net/v1/AUTH_d684780d-aafe-4772-bcbb-0f07d5f6edf3/a-container/data.txt?temp_url_sig=19f067d38dc532883e8f02be3b43a172c61e51d2&temp_url_expires=1445615769'
Some reference pages:
Here how to install and configure the swift client
http://sldn.softlayer.com/es/blog/waelriac/Managing-SoftLayer-Object-Storage-Through-REST-APIs
here how to create the temp URL
http://luisbg.blogalia.com/historias/74348
I hope it helps
Answer myself.
I finally wrote a code for it, after doing some more search on it including:
read related API codes from https://github.com/softlayer/softlayer-object-storage-ruby
read http://sldn.softlayer.com/es/blog/waelriac/Managing-SoftLayer-Object-Storage-Through-REST-APIs
after that, I found some hint from middle of the second document: the response Header contains this key!
X-Account-Meta-Temp-URL-Key
So, I wrote a code(method) for it and make pull request(https://github.com/softlayer/softlayer-object-storage-ruby/pull/10), and I hope it will merged soon.
anyway, If it is not accepted (yet), you can found my code at https://github.com/c12g/softlayer-object-storage-ruby

MagicalRecord delete core data store when rebooting the application

I don't know why but MagicalRecord delete my store every time I reboot the application, I saw in the documentation :
When using the default sqlite data store with the DEBUG flag set, if you change your model without creating a new model version, Magical Record will delete the old store and create a new one automatically. No more uninstall/reinstall every time you make a change! (see magicalRecord github page
Removed the DEBUG flag,Tried to create a new model version, MR is still deleting my store...
Help me please :-)
This may be a bug. Please add an issue to the github repo. Or, if you need to get going faster, you can peek into the code, and comment out the line that checks to see if your model is compatible with your persistent store.

Resources