Search Unity

Unity client / NodeJS server : how to sign and verify data ?

Discussion in 'Multiplayer' started by Jichaels, Feb 14, 2019.

  1. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Hi guys,

    as mentionned in the title, I'm using unity as a client, and connect to a nodeJS server using socket.io (with the BestHTTP asset).

    What I want to achieve : user1 get a license key (by email or w/e) that was signed by my server, enter the key in the app, client ask the server if the key is valid and has been signed, and if so user1's computer can play.
    This will only require an internet connexion when "registering" the license key, and then I'd store the key in a hashed file or something so user1 can play without contacting the server everytime.
    Simplified version : user1 only need to be connected once (the first time he launch the app), but I need to check at every launch if he's allowed to play.

    Client-side (in Unity c#) is working fine, what I do is basically hashing the key and storing it in a file, then hashing that file to verify users don't modify it.

    But then, I don't know what to do on server-side. Are there API that can achieve what I want to do ? Am I going in a wrong direction ?
    That's the first time I'm dealing with crypto, and I'm a bit lost :confused:

    Any help would be greatly appreciated !