# Encryption

**URL:** <https://techcommunity.softwareag.com/t/encryption/202450>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux, Adabas-Natural-Cloud\
**Created:** [January 15, 2019, 1:20pm UTC](https://techcommunity.softwareag.com/t/encryption/202450 "2019-01-15T13:20:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derick\_Meyer](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@Derick\_Meyer](https://techcommunity.softwareag.com/u/Derick_Meyer)\
**Post date:** [January 15, 2019, 1:20pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/1 "2019-01-15T13:20:19Z")

</div>

Is it possible to encrypt data to store in adabas  
Like password that is stored in plain text

---

<div class="post-metadata">

**Author:** ![James\_Gilpin1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/james_gilpin1/32/152_2.png) [@James\_Gilpin1](https://techcommunity.softwareag.com/u/James_Gilpin1)\
**Post date:** [January 15, 2019, 1:44pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/2 "2019-01-15T13:44:29Z")

</div>

[http://natural-adabas.blogspot.com/2006/06/adabas-security\_20.html](http://natural-adabas.blogspot.com/2006/06/adabas-security_20.html)

Going back a few years, but yes, it is possible

---

<div class="post-metadata">

**Author:** ![Derick\_Meyer](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@Derick\_Meyer](https://techcommunity.softwareag.com/u/Derick_Meyer)\
**Post date:** [January 15, 2019, 2:34pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/3 "2019-01-15T14:34:35Z")

</div>

Thank You for the info  
is there a howto example to use to store the values in a encrypted format

---

<div class="post-metadata">

**Author:** ![James\_Gilpin1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/james_gilpin1/32/152_2.png) [@James\_Gilpin1](https://techcommunity.softwareag.com/u/James_Gilpin1)\
**Post date:** [January 15, 2019, 2:39pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/4 "2019-01-15T14:39:11Z")

</div>

Which platform are you using? Mainframe? LUW?

---

<div class="post-metadata">

**Author:** ![Derick\_Meyer](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@Derick\_Meyer](https://techcommunity.softwareag.com/u/Derick_Meyer)\
**Post date:** [January 15, 2019, 3:12pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/5 "2019-01-15T15:12:08Z")

</div>

i am using luw natural for unix

---

<div class="post-metadata">

**Author:** ![James\_Gilpin1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/james_gilpin1/32/152_2.png) [@James\_Gilpin1](https://techcommunity.softwareag.com/u/James_Gilpin1)\
**Post date:** [January 15, 2019, 3:24pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/6 "2019-01-15T15:24:11Z")

</div>

Are you asking if the database can manage the encryption?

Or would you prefer to encrypt the data and then store it in the database?

---

<div class="post-metadata">

**Author:** ![Derick\_Meyer](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@Derick\_Meyer](https://techcommunity.softwareag.com/u/Derick_Meyer)\
**Post date:** [January 15, 2019, 3:42pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/7 "2019-01-15T15:42:47Z")

</div>

I wish to encrypt the data and then store it in the database if possible

---

<div class="post-metadata">

**Author:** ![James\_Gilpin1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/james_gilpin1/32/152_2.png) [@James\_Gilpin1](https://techcommunity.softwareag.com/u/James_Gilpin1)\
**Post date:** [January 15, 2019, 7:12pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/8 "2019-01-15T19:12:55Z")

</div>

One option, fairly intensive…

Use openssl to create a key pair (private/public)  
Create a script to encrypt  
Create a script to decrypt  
Create a subprogram to call the encrypt with the text to encrypt  
Create a subprogram to call the encrypt with the text to decrypt

Another option - create an internal table and swap value by digit… - not real secure, but better than nothing

Personally, I think you would be better off relying on encryption at rest - via ADASCR and storage utilities

---

<div class="post-metadata">

**Author:** ![James\_Gilpin1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/james_gilpin1/32/152_2.png) [@James\_Gilpin1](https://techcommunity.softwareag.com/u/James_Gilpin1)\
**Post date:** [January 16, 2019, 5:14pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/9 "2019-01-16T17:14:45Z")

</div>

Attached is an example program, subprogram, basic information for my previous instructions

[example.txt](https://techcommunity.softwareag.com/uploads/short-url/6cXnUg44QcJKUb3PnbpefecnYjG.txt) (3.13 KB)

---

<div class="post-metadata">

**Author:** ![James\_Gilpin1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/james_gilpin1/32/152_2.png) [@James\_Gilpin1](https://techcommunity.softwareag.com/u/James_Gilpin1)\
**Post date:** [January 17, 2019, 8:12am UTC](https://techcommunity.softwareag.com/t/encryption/202450/10 "2019-01-17T08:12:22Z")

</div>

FYI - For fun, I created a container based on the SoftwareAG Natural CE container that has this example code built in…

[https://hub.docker.com/r/niceine/mynat](https://hub.docker.com/r/niceine/mynat)

note: this is a linux container

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [April 30, 2019, 2:12pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/11 "2019-04-30T14:12:33Z")

</div>

> [@Derick Meyer](#):
>
> Is it possible to encrypt data to store in adabas  
> Like password that is stored in plain text

The password issue is a special kind of thing. I would use a hash-algorithm (maybe with salt, see [Salt (cryptography) - Wikipedia](https://en.wikipedia.org/wiki/Salt_(cryptography)) )

Natural has an implemented sha1-Hash-Algorhythm.

```auto

*
DEFINE DATA LOCAL
1 #INPUT-PARAMETER
  2 #I-STRING (A) DYNAMIC INIT <'The quick brown fox jumps over the lazy dog'>
1 #OUTPUT-PARAMETER
  2 #SHA1-SUM (B20)
LOCAL
1 #FUNC (I4)
1 #B156 (B156)
END-DEFINE
*
#FUNC := 0
CALLNAT 'USR4011N' #FUNC #B156 #I-STRING #OUTPUT-PARAMETER.#SHA1-SUM
write #SHA1-SUM
END
```

The idea is to store the sha1-sum instead of the Password itself.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:42pm UTC](https://techcommunity.softwareag.com/t/encryption/202450/12 "2021-04-02T15:42:08Z")

</div>


