Skip to main content

News

Topic: Advances in the Sphere JavaScript Library (Read 2767 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Rahkiin
  • [*][*][*]
Advances in the Sphere JavaScript Library
Hi All!

I have a couple of matters regarding the JavaScript library provided for Sphere:

Today I was coding on my engine, and I came across the Logging API in the function docs on the wiki.
I started to wonder, does anyone use this logging api? Especially more than just the 'print a line to a file': the grouping?

I am adding SHA1 and SHA256 hashing functions for files and raw files. It might be a good addition as MD5 is completely broken. I keep MD5 for legacy reasons.


// Rahkiin
  • Last Edit: March 20, 2014, 08:31:26 pm by Rahkiin

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Advances in the Sphere JavaScript Library
Reply #1
It's used extensively in a lot of older projects. Tung's persist.js for example is one of them. It is underused however, and most just generally print a line to file. I think it's a neat feature worth keeping. If you want to 'upgrade' that feature feel free to, and if you want to strip it you can too, since it is mainly used for debugging afterall. Make sure to gracefully fail if you do strip it out in case a game uses it, at least it'll just do nothing instead of fail.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Rahkiin
  • [*][*][*]
Re: Advances in the Sphere JavaScript Library
Reply #2
Alright. I'll look into making a nicer debug/log-api.

I edited my post to add about hashing.

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Advances in the Sphere JavaScript Library
Reply #3
While it is true MD5 is broken for security reasons, it still has a use. For example, you may want to compare two files or other pieces of data, it's not so bad and cheaper and easier than SHA. While on the topic of broken encryption algorithms, SHA-1 is broken too so SHA-256 is really your best bet. I too added SHA-1/256 to my Sphere engine. So +1 on that feature.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Rahkiin
  • [*][*][*]
Re: Advances in the Sphere JavaScript Library
Reply #4
What is the API you are using? I have my FileSystem.md5()/sha1/sha256, FileSystem.File.prototype.md5/sha1/sha256 and same for RawFile. Do you have some SHA1HashForFile() function?

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Advances in the Sphere JavaScript Library
Reply #5
My engine re-implements the old Sphere API for backwards game compliance. My shim will be different and do the opposite of the kind of shim you'd make.

Example:
Code: (javascript) [Select]

HashFromFile(filename, sha); // sha = true, hashes in sha-1, sha=false or undefined, hashes in MD5


This way the old functionality still works if you don't add SHA as a parameter, and if you do you can instantly upgrade your project from the old MD5 hash to the newer SHA hashes. Now, I use SHA-1 for now, but soon I'll change this API to take a constant so you can go between MD5, various types of SHA and other types of hash functions.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Rahkiin
  • [*][*][*]
Re: Advances in the Sphere JavaScript Library
Reply #6
Alright. We should be making some documentation for each engine, so we can create shims for it. I create a shim for 1.6, and 1.5, and I can add any shim I want of course. I wondered about your API so I can incorporate that in the shim.