Skip to content

Commit 819ab72

Browse files
committed
Add support for sha256, still defaults to sha1
1 parent 19fb016 commit 819ab72

File tree

5 files changed

+75
-19
lines changed

5 files changed

+75
-19
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ Usage
2727
-----
2828

2929
This library requires:
30-
* [CryptoJS](http://code.google.com/p/crypto-js/), that can be found
31-
in the `vendor` directory.
30+
* [jsSHA](https://github.com/Caligatio/jsSHA), used to calculate checksums.
31+
You can download it from their website or use the minified version that can be found in the
32+
`vendor` directory.
3233

3334
Add these libraries and `bigbluebutton-api.js` to your page. Then you can get the links to the API calls
3435
with a code similar to this example (code in Coffeescript):

lib/bigbluebutton-api.js

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bigbluebutton-api.coffee

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ class BigBlueButtonApi
55
# `url`: The complete URL to the server's API, e.g. `http://server.com/bigbluebutton/api`
66
# `salt`: The shared secret of your server.
77
# `debug`: Turn on debug messages, printed to `console.log`.
8-
constructor: (url, salt, debug=false) ->
8+
# `opts`: Additional options
9+
constructor: (url, salt, debug=false, opts={}) ->
910
@url = url
1011
@salt = salt
1112
@debug = debug
13+
@opts = opts
14+
@opts.shaType ?= 'sha1'
1215

1316
# Returna a list with the name of all available API calls.
1417
availableApiCalls: ->
@@ -167,7 +170,12 @@ class BigBlueButtonApi
167170
query ||= ""
168171
console.log "- Calculating the checksum using: '#{method}', '#{query}', '#{@salt}'" if @debug
169172
str = method + query + @salt
170-
c = Crypto.SHA1(str)
173+
if @opts.shaType is 'sha256'
174+
shaObj = new jsSHA("SHA-256", "TEXT")
175+
else
176+
shaObj = new jsSHA("SHA-1", "TEXT")
177+
shaObj.update(str)
178+
c = shaObj.getHash("HEX")
171179
console.log "- Checksum calculated:", c if @debug
172180
c
173181

vendor/crypto-sha1-2.5.3.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)