Document Type | Technical Information
Category | Utility
Applicable Product Versions | Tibero 6, Tibero 7
Document Number | TUTTI033
Overview
You can use tbwrap to encrypt source files written in the tbPSM language, save them as files, and create procedures, packages, functions, etc., in the database using the encrypted DDL statements.
$ tbwrap
tbWrap 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Usage: tbwrap [controls]
Controls:
iname Input file path
oname Output file path [default:<input file name>.tbw]
Example:
tbwrap iname=psm.sql --> psm.tbw is generated.
tbwrap iname=psm.sql oname=abc.tbw --> abc.tbw is generated.
Method
How to Use
-- Output/save the file in the current directory with only the extension changed to tbw
$ tbwrap iname=test.sql
-- Output/save the file as test_enc.tbw in the current directory
$ tbwrap iname=test.sql oname=test_enc.tbw
-- Specify directory for output/save
$ tbwrap iname=$HOME/work/test.sql oname=$HOME/work/test_enc.tbw
Usage Example
This example shows the process of encrypting a function (fn_test.sql) and creating it in the database.
$ cat fn_test.sql
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
create or replace function fn_test (
in_str varchar2
) return varchar2
is
begin
return in_str ;
end ;
/
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Encrypt the function fn_test.sql into fn_test_enc.tbw using tbwrap.
$ tbwrap iname=fn_test.sql oname=fn_test_enc.tbw
tbWrap 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Processing fn_test.sql to fn_test_enc.tbw...............................Done
$ cat fn_test_enc.tbw
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
create or replace function fn_test wrapped
CwjTAHTE0wUuhqqxDYjjhGz2Wd6yUrzQWk9z/+zxOkXlxtIoVXgQt+DZ3zhmc2unVa0xT8ymqa9VslnjZDg7b0U9RbpY0PuGusQRCEEly+wY2DiGENXZwMCnwbaLUQ1ZQ2d8X/te+VMcmpi0B8AvMw==
/
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Then, apply it properly in the database and verify the results.
$ tbsql tibero/tmax
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to Tibero.
SQL> @fn_test_enc.tbw
Function 'FN_TEST' created.
SQL> select fn_test('TEST!') from dual ;
FN_TEST('TEST!')
-----------------------
TEST!
SQL> select text from user_source where name = 'FN_TEST' order by line ;
TEXT
------------------------------------------------------------------------------------------------------------------------
create or replace function fn_test wrapped
CwjTAHTE0wUuhqqxDYjjhGz2Wd6yUrzQWk9z/+zxOkXlxtIoVXgQt+DZ3zhmc2unVa0xT8ymqa9VslnjZDg7b0U9RbpY0PuGusQRCEEly+wY2DiGENXZwMCn
wbaLUQ1ZQ2d8X/te+VMcmpi0B8AvMw==
Caution
- When distributing packages, the usage instructions should be exposed to users, but the implementation details should not be disclosed.
Therefore, do not encrypt the declaration part; only encrypt the implementation part for distribution.- Encrypted statements cannot be decrypted, so be careful not to lose the original source code.
- Triggers are not encrypted, so ensure that encrypted subprograms are called within the trigger's internal statements.
- The tbwrap program does not perform syntax checking, so syntax errors can only be detected by compiling the encrypted file.