CryptoJS AES Encryption in React Native - encryption

How do I encrypt and decrypt an epub/zip file in react native? I am using react-native-fetch-blob for file streaming. I have also posted this question previously in detail with no result. Here is the link if you need. Also the link of CryptoJS.
I was reading the epub/zip file in base64 format which I think as equivalent of reading in binary format (or Am I wrong?). It works with single text file though.
Any Solutions? Thankyou.

Related

Decode and parse a file encoded with BER(Basic encoding rules) to output relevant fields to csv without a .asn (ASN.1) schema?

The files I have been given are sample CDR files(Call Detail Records)
SGSN / GGSN data format: ASN.1 Basic Encoding Rules (BER).
The files have no extensions and I do not have a schema to work with. How can I approach this?
Vasil is correct that, to a degree, BER can be decoded without a schema. However, if the schema uses implicit tags, you won't get very far until you have blocks of data that you have no idea how to interpret. You will very likely need to either get the schema files or use a tool that has the appropriate schema definitions built-in.
If the files follow 3GPP 32.297 and 32.298, those specifications are freely available and you may be interested in https://www.3gpp.org/ftp/Specs/archive/32_series/32.298/ASN.1/
My company has a visual editor that can handle 32.297 CDR files. You can get a trial at: https://www.obj-sys.com/products/asn1ve/index.php. It comes with some CDR specs built in, so you might not need to get the schemas yourself.
To a certain extent it is possible to decode any valid BER encoded data without having the ASN.1 schema.
Try decoding the file using the unber tool from the asn1c project or this online decoder.

SQLite database shows question marks (???) instead of these Unicode characters (தமிழ்)

I imported a CSV file containing Unicode into an SQLite database but instead of seeing the text, all that I see are question marks. Like this, "???". The encoding is UTF-8 (I've mentioned below what happened when I tried UTF-16). The SQLite manager I'm using is DB Browser for SQLite.
This is the Unicode that I typed: தமிழ்
Now, according to this answer in Stackoverflow, SQLite stores text data as Unicode. So the fact that my text is Unicode can't be the problem.
The characters I'm trying to use belong the language Tamil. I'm trying to use it with Unicode. According to Wikipedia, encoding for Tamil is called TACE16. It's a 16-bit Unicode based character encoding.
So then I set the encoding as UTF-16 when I imported the CSV file. But the file doesn't even show up in the database after importing when I do that. But it says import is successful.
Then I tried importing the CSV file with UTF-8 encoding as usual. But after importing I right clicked the row header, selected "Set Encoding" and set it to UTF-16. Now it didn't show question marks but it shows something like Chinese characters. This is what it shows now: 㼿㼿.
I tried setting TACE16 while importing. I also tried setting it manually. But it said it's either an incorrect encoding or it is not supported.
Further searching online didn't turn up anything. Could someone tell me how I can fix this issue? Basically, I want this text "தமிழ்" to show in the SQLite database after importing the CSV file which has the text.
Thank you so much. I would really appreciate your help.
I had similar issue once but in my case the problem were only on the DB software I used to visualize DB tables. Have you tried to retrieve your data from the database? Are they right when you retrieve them?
Anyways if you tell us what tools are you exactly using for doing what it is impossible to find a solution in your specific case.
OK, it turns out the issue was my csv file. I edited it in excel and I guess excel saved it using another encoding. I'm still not sure what's the exact issue but I'll just write about how I fixed it.
I opened Notepad and typed out the data separated by commas. I saved the file with the extensions csv. Here's the important thing. You have to change the encoding to Unicode. There's a drop down menu just left of the save button. Use that. Here's a link to a youtube video that shows you how.
Also, you don't need to type everything in a Notepad. It can get tedious.
Type everything out in Google Spreadsheets and export download it as a CVS file. It works. If you have to use Notepad, type the data in excel, concatenate everything in each row with using a formula, and copy paste it into a notepad. Don't forget to add a comma between each cell info using the formula in excel.

Convert InputStream to Mediaplayer

I use android platform . I have file in InputStream Datatybe , I want to convert it to MediaPlayer and play it
I have two suggestions for you:
Get the entire input into a properly formatted file, and pass that file to MediaPlayer. You're going to have to figure out if your data is formatted properly and how to format it.
Instead of using MediaPlayer, use MediaCodec (http://developer.android.com/reference/android/media/MediaCodec.html) where instead of passing a file or a link you're passing the data itself. With this solution, you're going to have to figure out if you're passing the data properly to Media Codec, but I suspect this is the solution you're looking for. The google documentation does have an example to get you started a bit.
Good luck to you!
What is the format of the data? MP4?
If it is a standard container like MP4 and is a file accessible as a URI in local filesystem (file://) or network (http://) then you should use Google's ExoPlayer library, with demo code here.
I would only resort to using MediaCodec if you have a custom container or transport mechanism.

Save Encrypted data in text file

I have encrypted my output data. I want to save that data in a file. When I am saving it in a text file, I believe it is not saved properly. Because, I can't get proper data after decryption from that file. I am using C#. Do I need to implement my own file format? Please help me.
i belive it's Unnecessary to ask you if you tried encrypting / decrypting some simple string.
try using those methods for saving they are soo simple:
System.IO.File.WriteAllBytes();
System.IO.File.WriteAllText();
System.IO.File.ReadAllBytes();
System.IO.File.ReadAllText();

Check the encoding of text in SQlite

I'm having a nightmare dealing with non Eurpean texts in SQlite. I think the problem is that SQlite isn't encoding the text in UTF8. So I want to check what the encoding is, and hopefully change it to utf8. I encoded a CSV in UTF8 and simply imported it to SQlite but the non-roman text is garbled.
I would like to know:
1)how to check the encoding.
2)How to change the encoding if it is not utf8. I've been reading about Pragma encoding, but I'm not sure how to use this.
I used OpenOffice 3 to create a spreadsheet with half ENglish and half Japanese text. Next I saved the file as a CSV using utf8. This part seems to be ok. I also tried to do it using Google Docs and it worked fine. Next I opened SQlite Browser and did CSV import. The ENglish text shows up perfectly, but the Japanese text is garbled symbols. I think sqlite is using a dfferent encoding (perhaps utf16?).
You can test the encoding with this pragma:
PRAGMA encoding;
You cannot change the encoding for an existing database. To create a new database with a specific encoding, open a SQLite connection to a blank file, run this pragma:
PRAGMA encoding = "UTF-8";
And then create your database.
If you have a database and need a different encoding, then you need to create a new database with the new encoding, and then recreate the schema and import all the data.
However, if you have a problem with garbled text it's pretty much always a problem with one of the tools being used, not SQLite itself. Even if SQLite is using a different encoding depending, the only end result is that it will cause some extra computation as SQLite converts from stored encoding to API-requested encoding constantly. If you're using anything other than the C-level API's, then you should never care about encoding--the API's used by the tool you're using will dictate what encoding should be used.
Many SQLite tools have shown issues mangling text into our out of SQLite, including command line shells. Try running SQLite from a command line and tell it to import the file itself instead of going through SQLite Browser.
I also experienced a similar issue. I used SQLiteStudio to access the database and export data. SQLiteStudio does not handle UTF8 special characters correctly, however, the SQLite database itself contains the correct UTF8 characters. I ended up writing a code snippet in C# to connect to the database, run my query, and export the data. This approach worked fine.

Resources