question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the proper way to encrypt table id?

See original GitHub issue

Hi,

Im using uuid for my primary keys but i want is to encode uuid before returning it to user.

for example:

{
  id: "a3ae9976-94b4-46ce-afdd-76a665ee7316"
}

what i want to do is to make something like this:

let list = model.fetchAll().map((item) => {
  return {id: encode(item.id)};
});

which will become

{
  id: "45IOgC2FDfr5bkbS"
}

Best Regards, Jason Villalon

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonvillaloncommented, Aug 12, 2017

Hi!

Thank you for your reply. the combination of your 2 suggestions solved my problem.

what happen is all primary keys which is “id” is added as hidden using visiblity plugin and all the foreign keys are manually encoded and decoded in parse and format methods.

encoding and decoding id (primary key) in parse and format will cause of unpopulated related records. and the reason why i cannot add the foreign keys in hidden is that it will not being populated when fetching withRelated.

All in all. thank you very much. closing this issue now.

Best Regards, Jason Villalon

0reactions
chamini2commented, Aug 12, 2017

Another alternative is using the Visibility plugin:

Model.extend({
  hidden: ['id'],
  parse(attrs) {
    attrs.enconded_id = encode(attrs.id);
  },
  submodules() {
    return this.hasMany(Modules, 'parent_id', 'id');
  }
})

That way you create relationships using id but the users only see enconded_id.

Read more comments on GitHub >

github_iconTop Results From Across the Web

An overview of the column level SQL Server encryption
SQL Server encrypted column datatype should be VARBINARY. In our CustomerData table, the BankACCNumber column data type is Varchar(10).
Read more >
Encrypt a Column of Data - SQL Server & Azure Synapse ...
This article describes how to encrypt a column of data by using symmetric encryption in SQL Server using Transact-SQL.
Read more >
Column-Level SQL Server Encryption Example Using SQL ...
1. In Object Explorer, right-click the Person table and select Encrypt Columns. Encrypting columns in SSMS. 2. In the Always Encrypted ...
Read more >
what is a good way to encrypt a id in a url? - Stack Overflow
Use HTTPS, everything is encrypted except the address portion of the URL. – zaph. Sep 2, 2016 at 17:28. 4.
Read more >
Encrypt And Decrypt Column Data In SQL Server - C# Corner
Symmetric Key - can be encrypted by using many options, like certificate, password, symmetric key. There are different algorithms available for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found